How to separate fields with space or tab in awk

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\t%s\n", $5, $1)'} a.txt ;

Another awk-specific technique, use the "output field separator"

ls -la | awk -v OFS='\t' '{print $5, $1}'

The comma is crucial here.


A simple way to get tabs is:

awk {'print $5"\t"$1'}