I have files under a common folder which contain numbers as a part of them. I am trying to access these files serially through perl command executed via bash script. When I try to obtain filenames based on serial numbers in filenames it does not work. How can I resolve this.
Example filenames:
test_S1_L001.sorted.bam
abc_S2_L001.sorted.bam
cdf_S3_L001.sorted.bam
I am trying to extract individual filenames using following command in bash
script.pl $mapFolder/*S{$id}_L001.sorted.bam
Where, $id is numbers after S e.g 1, 2 ,3 provided from the bash script.
mainScript.sh 1
mainScript.sh 2
mainScript.sh 3
However this command is giving me error below
failed to open "mapFolder/*S1_L001.sorted.bam" for reading: No such file or directory
It should ideally take full file name for the perl script as
script.pl mapFolder/test_S1_L001.sorted.bam