Off topic:HELP with variable assignment in bash loop for
0
0
Entering edit mode
5.2 years ago

Hi guys,

I'm pretty new in programming, very naive to be honest and I need some help, if possible.

I need to run a couple of commands for different files, and I thought using the loop for would be the best option. However, I don't know exactly how to NOT overwrite the output, I mean, I need one different file as output for each of the input files. I have tried something like:

for i in "file1.vcf" "file2.vcf" do

PASS filtering

grep -e "#" -e "PASS" /home/hpz440/Documents/example/input/$i > /home/hpz440/Documents//example/output/$i_PASS.vcf
echo $i

done

It didn't work. My idea was to use the name of the file in the output file name, so I wouldnt have the problem with overwriting.

Do you have any idea how can I improve this? The next step once this work, would be insert fiile1.vcf, file2.vcf as a list, so I could edit or add other files to analyze.

Thank you!

bash • 542 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 3138 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6