Formatting output with printf: truncating or padding
问题 I would like to produce the following output: > Avril Stewart 99 54 > Sally Kinghorn 170 60 > John Young 195 120 > Yutte Schim... 250 40 As you can see, names shorter than 14 characters are padded with spaces. Names longer than 15 characters are truncated: 'Yutte Schimmelpenninck' truncates to 'Yutte Schim...'. Here is what I have tried to achieve this (the variables $name , $height , and $weight are extracted from files, and a loop runs the printf command on each file data): printf '%-14s -