If/Else loop for grep count
1
0
Entering edit mode
4.2 years ago
mrmrwinter ▴ 30

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

grep if else python snakemake • 746 views
ADD COMMENT
0
Entering edit mode

In the future please highlight code with the format bar.

enter image description here

ADD REPLY
0
Entering edit mode

Will do in future, sorry

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
1
Entering edit mode
4.2 years ago
 for F in ~/*.txt ~/*.fa ; do (grep '^>' -m1 "${F}" && mv "${F}" "DIR1") || mv "${F}" DIR2  ; done
ADD COMMENT

Login before adding your answer.

Traffic: 1407 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