On Wed, Jan 30, 2013 at 06:54:14AM +1100, Matthew Cengia wrote:
...
I would like to know if to display the 3 following lines:
foo bar base
foo bar base foo bar baz
foo bar base foo bar baz foo bar base
it is the appropriate way to write:
line1="foo bar base"
line2="foo bar base foo bar baz"
line3="foo bar base foo bar baz foo bar base"
printf "%$((${#line1}+10))s\n%$((${#line2}+10))s\n%$((${#line3}+10))s\n" "$line1"
"$line2" "$line3"
If yes, printf is hard to read (and write) too. If not, how can we write
this most simply ? ( with printf )
printf " %s\n" "$line1" "$line2" "$line3"
--
Chris F.A. Johnson, <http://cfajohnson.com/>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)