I have two principal data files (datafile1 and datafile2) that are split by chromosome, so I have a number of files that look like this:
datafile1_chr1.txt
datafile1_chr2.txt
datafile1_chr3.txt
datafile2_chr1.txt
datafile2_chr2.txt
datafile2_chr3.txt
I'm trying to write a bit of Bash code that can identify the two datafiles from the same chromosome and run an R script using those two files as variables.
What I have at the moment is very verbose:
Rscript --vanilla matchdata.R datafile1_chr1.txt datafile2_chr1.txt
Rscript --vanilla matchdata.R datafile1_chr2.txt datafile2_chr2.txt
Rscript --vanilla matchdata.R datafile1_chr3.txt datafile2_chr3.txt
Could someone suggest a one line solution for this? I am not sure how I could encorporate variables to help me here.