From a559fd580f0154bfe45f7e1c102b1c27e469e980 Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Thu, 12 Nov 2020 03:44:19 +0000 Subject: [PATCH] Add variable spacing example to printf --- sheets/printf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sheets/printf b/sheets/printf index 1563c4c..2a093ad 100644 --- a/sheets/printf +++ b/sheets/printf @@ -26,3 +26,7 @@ printf '%#.3d\n' 12 # As above, but instead, space-pad the number. Prefix the `3` with a hyphen # (`-`) to left-align the number, causing the padding to occur on the right. printf '%3d\n' 12 + +# Set a field's spacing by using an integer provided as a variable. This is +# incredibly useful when you're dealing with inconsistent field lengths. +printf '%*s\n' $Integer 'Example Field'