Shell One Liners

Renaming file name.old to – To test things first, insert ‘echo’ between ‘do mv’ (below).

$ for i in *.input; do mv $i ${i/name.old/}; done

Running application in loops on many input files

$ for i in *.input; do ./application $i; done

Running fastacmd in loops on many *.input files and creates *.out files

$ for i in *.input; do fastacmd -d /data/../database_name -i $i > $i.out; done

Running SAM’s target99 on many input files

$ for i in *.pep; do target99 -db /usr/../database_name -seed $i -out $i; done

Search in > 10,000 files for pattern and prints occurences together with file names.

$ for j in 0 1 2 3 4 5 6 7 8 9; do grep -iH *$j.seq; done

Example of how to run an interactive application (tmpred) that asks for file name input/output

$ for i in *.pep; do echo -e “$inn17n33nnn” | ./tmpred $i > $i.out; done

Running BLAST2 for all *.fasa1/*.fasta2 file pairs in the order specified by file names and writes results into one file. This example uses two variables in a for loop. The content of the second variable gets specified in each loop by a replace function.

$ for i in *.fasta1; do blast2 -p blastp -i $i -j ${i/_*fasta1/_*fasta2} >> my_out_file; done

Running BLAST2 in all-against-all mode and writes results into one file; ‘-F F’ turns low-complexity filter off

$ for i in *.fasta; do for j in *.fasta; do blast2 -p blastp -F F -i $i -j $j >> my_out_file; done;

Be the first to comment

Leave a Reply

Your email address will not be published.


CommentLuv badge