Thursday, July 17, 2014

How to select two or more columns from a file / multiple files in Unix

If you want to e.g. select first 3 columns from a file use awk command:

awk '{print $1,$2,$3}' test.txt > output.txt

To repeat this for all files in a folder:

for filename in *; do awk '{print $1,$2,$3}' ${filename} > ${filename}.cut; done

No comments:

Post a Comment