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!
0 answers
No answers yet.
Log in to answer this question.
Could you elaborate on this please :
Try something like this :
Remove the double
//on the output of your command line.Documents//exampleshould beDocuments/exampleThis is not a
Forum. It is aquestion.Hello yasminsoareslima!
We believe that this post does not fit the main topic of this site.
Not strictly a bioinformatics question (basic shell scripting). Take a look at walkthroughs like https://www.cyberciti.biz/faq/bash-for-loop/ for example. Pay particular attention to `${i}` syntax.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!
Thank you for the information and the kind response.
No problems at all.
Sorry,
Yasmin