Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cut multiple columns from several files and print the output to different files

I have several files and I only want to take specific columns from it. At the moment, I am using the following code:

$cut -f 1,2,5 AD0062-C.vcf > cutAD0062.txt

However, to speed up the process I was wondering if I could cut the same columns (fields 1,2,5) in multiple files and then print the output to several different files. I.e columns 1,2,5 of files AD0063-C.vcf, AD0064-C.vcf, AD0065-C.vcf should output results to separate files: cutAD0063.txt, cutAD0064.txt, cutAD0065.txt?

like image 845
user1458512 Avatar asked Jun 15 '12 11:06

user1458512


1 Answers

You can write a for...loop:

for i in AD*-C.vcf
do
    cut -f 1,2,5 $i > cut${i%-C.vcf}.txt
done
like image 94
kev Avatar answered Oct 18 '22 17:10

kev