Thursday, February 23, 2012

print all columns except last one

in awk:

print all columns except the first one column:
awk '{$1=""; print $0}' file

print all columns except the last one column:
awk '{$NF=""; print $0}' file

or acting as a geek, you can use the "rev" command to reverse the lines, then cut from the second field, then rev again:

rev file | cut -f2- | rev

Motivated from:http://lowfatlinux.com/linux-columns-cut.html#ixzz1nFIa9DZm


The unix command 'column' seems working for this purpose, but I did not figure it out yet. Here is column document:
http://www.eskimo.com/~scs/src/column.man.html

1 comment: