How to print all the columns after a particular number using awk?
Solution 1:
awk '{ s = ""; for (i = 9; i <= NF; i++) s = s $i " "; print s }'
Solution 2:
When you want to do a range of fields, awk
doesn't really have a straight forward way to do this. I would recommend cut
instead:
cut -d' ' -f 9- ./infile
Edit
Added space field delimiter due to default being a tab. Thanks to Glenn for pointing this out
Solution 3:
awk '{print substr($0, index($0,$9))}'
Edit: Note, this doesn't work if any field before the ninth contains the same value as the ninth.