Showing posts with label rev. Show all posts
Showing posts with label rev. Show all posts

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

Tuesday, September 09, 2008

reverse lines of file

use rev filename. For example,

[xianjund@douglasgran hypotest]$ head test11.data 
ENSG00000007372 ENSG00000109911 ENSG00000121690
ENSG00000007372 ENSG00000149100 ENSG00000170959
ENSG00000043355 ENSG00000175198 ENSG00000102452
ENSG00000172845 ENSG00000115840 ENSG00000091428

[xianjund@douglasgran hypotest]$ rev test11.data
09612100000GSNE 11990100000GSNE 27370000000GSNE
95907100000GSNE 00194100000GSNE 27370000000GSNE
25420100000GSNE 89157100000GSNE 55334000000GSNE
82419000000GSNE 04851100000GSNE 54827100000GSNE

It's cool, hmm?