Thursday, May 2, 2024
123
rated 0 times [  123] [ 0]  / answers: 1 / hits: 414695  / 2 Years ago, fri, june 17, 2022, 9:59:36

While playing with awk I came to execute:



ls -la >> a.txt ; awk {'print $5  $1'} a.txt ;


This is giving output like:



53277-rw-------
52347-rw-------


How can I get a space between these two friends of output?


More From » command-line

 Answers
7

Just change the line to



ls -la >> a.txt ; awk {'print $5 "        " $1'} a.txt ;


this should print the output with spaces.



Hope this helps.



Edit:



As suggested by McNisse you can use printf, which would provide you good output format



ls -la >> a.txt ; awk {'printf ("%5s	%s
", $5, $1)'} a.txt ;

[#33550] Saturday, June 18, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
umplegitimat

Total Points: 137
Total Questions: 126
Total Answers: 118

Location: Saint Pierre and Miquelon
Member since Sat, Aug 21, 2021
3 Years ago
;