Tuesday, 21 March 2017

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



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



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

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...