PDA

View Full Version : [SOLVED] help with awk



Drenriza
November 25th, 2010, 10:33 AM
if i do this command

ls -lah | awk '{ print $3 $4 $5 }'
and get this output

cristiancristian4,0K
how would i be able to paste spaces into the text so it would stand like

cristian cristian 4,0K
instead

Thanks on advance.

Arndt
November 25th, 2010, 10:55 AM
if i do this command

ls -lah | awk '{ print $3 $4 $5 }'
and get this output

how would i be able to paste spaces into the text so it would stand like

instead

Thanks on advance.

If you want spaces, output spaces:


ls -lah | awk '{ print $3 " " $4 " " $5 }'

DaithiF
November 25th, 2010, 10:55 AM
ls -lah | awk '{ printf "%s %s %s\n", $3,$4,$5; }'

Drenriza
November 25th, 2010, 11:06 AM
If you want spaces, output spaces:


ls -lah | awk '{ print $3 " " $4 " " $5 }'

Worked as intended :p

Thanks.