executing a bash script 100 times -


i writing shell script choose randomly choose 200000 lines fastq file (reads_qc.fastq), run python script (counts.py) on smaller file (file1.fastq) , count number of lines in output file (summary) produced python script. code,

cat reads_qc.fastq |awk '{ printf("%s",$0); n++; if(n%4==0) { printf("\n");} else { printf("\t\t");} }' |shuf  |head -n 200000 |sed 's/\t\t/\n/g' |awk '{print $1 > "file1.fastq"}'  python counts.py file1.fastq > summary  wc -l summary 

can suggest how can make script these opeartions 100 times.

you can use while loop , append results of each summary file using '>>' operator instead of '>':

#!/bin/sh  count=100  while [ $count -lt 100 ]     cat reads_qc.fastq |awk '{ printf("%s",$0); n++; if(n%4==0) { printf("\n");} else { printf("\t\t");} }' |shuf  |head -n 200000 |sed 's/\t\t/\n/g' |awk '{print $1 > "file1.fastq"}'     # append summary file instead of overwrite.     python counts.py file1.fastq >> summary     count=`expr $count + 1` done 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -