Say I have 20 different files. First 10 files end with .counts.tsv and the rest of the files end with .libsize.tsv. For each .counts.tsv there are matching .libsize.tsv files. I would like to use a for loop for selecting both of these files and run an R script for on those two files types.
Here is what I tried,
#!/bin/bash
arti='/home/path/tofiles'
for counts in ${arti}/*__counts.tsv ; do
for libsize in "$arti"/*__libsize.tsv ; do
Rscript score.R ${counts} ${libsize}
done;
done;
The above shell script iterates over the files more than 200 times whereas I have only 20 files. I need the Rscript to be executed 10 times for both files. Any suggestions would be appreciated.
countsandlibsizemyFile.libsize.tsvandmyFile.__counts.tsvThen you only need 1 loop, strip out the extension from the variable returned by the loop and add it back in to 2 copies on yourRscriptline, ie.Rscript ${myF}.__counts.tsv ${myF}.__libsize.tsv. Good luck..count.tsvfile there is a matching.libsize.tsvis present therefore in total 20. Therefore, at the end the Rscript should only iterate 10 times