I have 20 files of interest in a directory. They can be split into 5 groups, each group identified by a number from 626 to 630 in the file name.
For example, there might (hypothetically) be a file named
the-quick-brown-fox-jumps-over-627-lazy-dogs_1_bbduk.fq
.
I would like to iterate through each group and temporarily store the paths to the files as text variables
(to be used with other commands within the for
loop).
This is what I have for now:
for i in {626..630};do
fw1=$(/scratch/[username]/data/*"$i"-*_1_bbduk.fq)
fw2=$(/scratch/[username]/data/*"$i"_*_1_bbduk.fq)
rv1=$(/scratch/[username]/data/*"$i"-*_2_bbduk.fq)
rv2=$(/scratch/[username]/data/*"$i"_*_2_bbduk.fq)
done
Issue: I get the correct path (there is only one option for each of them), but it says "Permission denied", and I seem unable to use the variable as text later on. It looks like bash is trying to execute it, which is not what I want.
I've tried adding single quotes around (e.g., fw1='$(/scratch/[username]/data/*"$i"-*_1_bbduk.fq)'
, but that removes the wildcards. I've considered double quotes ( " " ), but I'm not sure how to use them without messing with the "$i" variable. I've tried using echo
(e.g., fw1=echo $(/scratch/[username]/data/*"$i"-*_1_bbduk.fq)
but that still has the 'permission denied' issue.