If/Else loop for grep count
Im trying to write an if-else loop that does the following
grep -c ^">" <file>
If results of grep are >0, move file to location1 Else move file to location 2
So far i have:
def numfasta = grep -c ^'>' {input} if [[ $numfasta -gt 0 ]] ; then mv {input} {output.denoise} else mv {input} {output.rerep} fi
but this is not working
Thanks
• 1,294 views
•
link
1 answer
for F in ~/*.txt ~/*.fa ; do (grep '^>' -m1 "${F}" && mv "${F}" "DIR1") || mv "${F}" DIR2 ; done
• 0 views
•
link
Log in to answer this question.
In the future please highlight code with the format bar.
Will do in future, sorry
No problem at all, was just a reminder :-) It simply makes post more structured and this in turn increases your chance of a good answer.