Using awk to print all columns from the nth to the last

Andy picture Andy · Jun 2, 2010 · Viewed 496.2k times · Source

This line worked until I had whitespace in the second field.

svn status | grep '\!' | gawk '{print $2;}' > removedProjs

is there a way to have awk print everything in $2 or greater? ($3, $4.. until we don't have anymore columns?)

I suppose I should add that I'm doing this in a Windows environment with Cygwin.

Answer

zed_0xff picture zed_0xff · Jun 3, 2010

will print all but very first column:

awk '{$1=""; print $0}' somefile

will print all but two first columns:

awk '{$1=$2=""; print $0}' somefile