I will like to grep a particular pattern from 244 files and generate respective output files for each of them in a single command, how do I do that?
My command for a single file is as follows:
grep -v '@SQ' *.sam | grep -v '@HD' cut -f 3 | sort | uniq -c | sort -nrk1 > output_count_file.txt
Instead of doing this 244 times for each individual file, how do I do it at once?
Examples of my input files are:
And I would like to grep some information from these input files into their respective output files e.g.:
From these output files, I need to grep again to combine information from the output files to another file.
If I do grep for one of these files e.g. A1_001.fastq.sam, I will get the following information:
I need to identify gene names from the second column (e.g. chr20:4804587-4804609) by comparing to a reference file which has the following information:
GTGCGCAGCGCTGAGTGTCG YBEY NM_001006114_utr5_0_0_chr21_47706267_f;NM_058181_utr5_0_0_chr21_47706267_f chr21 47706143 47706165
AGCAGGCGGACAGTAGGACG AUP1 NM_181575_utr5_11_0_chr2_74756757_r chr2 74757053 74757075
TAGGGGCAATGAATGGCGAG APEX2 NM_001271748_utr5_0_0_chrX_55026756_f;NM_014481_utr5_0_0_chrX_55026756_f chrX 55026610 55026632
Hope my question is not too complicated.