Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

awk

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.

like image 231
Andy Avatar asked Jun 02 '10 21:06

Andy


People also ask

What is awk '{ print $3 }'?

txt. If you notice awk 'print $1' prints first word of each line. If you use $3, it will print 3rd word of each line.

What is awk '{ print $2 }'?

awk '{ print $2; }' prints the second field of each line. This field happens to be the process ID from the ps aux output. xargs kill -${2:-'TERM'} takes the process IDs from the selected sidekiq processes and feeds them as arguments to a kill command.


1 Answers

Print all columns:

awk '{print $0}' somefile 

Print all but the first column:

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

Print all but the first two columns:

awk '{$1=$2=""; print $0}' somefile 
like image 120
zed_0xff Avatar answered Nov 01 '22 17:11

zed_0xff