Wednesday, November 14, 2012

How to cut columns from files in Unix via Terminal

If you have a file that is too big to manipulate in Excel (>1,000,000 rows) and you need to cut column/s from that file use Unix command cut.

E.g. if you need to cut column 3 from the file and write it into a new file
cut -f 3 file.txt > newfile.txt

If you need to cut multiple columns separate them with comma:
cut -f 3,4 file.txt > newfile.txt

No comments:

Post a Comment