Difference between revisions of "Printf formatting"

From thelinuxwiki
Jump to: navigation, search
Line 1: Line 1:
just go here...
+
if you want information overload...go here [http://wiki.bash-hackers.org/commands/builtin/printf http://wiki.bash-hackers.org/commands/builtin/printf]
  
http://wiki.bash-hackers.org/commands/builtin/printf
+
 
 +
'''simple column width formatting + justification'''
  
 
  $ printf "%10s%10s\n" "foo" "bar"                                                                                                             
 
  $ printf "%10s%10s\n" "foo" "bar"                                                                                                             

Revision as of 20:16, 31 October 2013

if you want information overload...go here http://wiki.bash-hackers.org/commands/builtin/printf


simple column width formatting + justification

$ printf "%10s%10s\n" "foo" "bar"                                                                                                            
      foo       bar
$ printf "%-10s%10s\n" "foo" "bar"                                                                                                           
foo              bar
$ printf "%10s%-10s\n" "foo" "bar"                                                                                                           
      foobar       
$ printf "%-10s%-10s\n" "foo" "bar"                                                                                                          
foo       bar