I want to retrieve the first part of a file name and iterate through a list of files. File names are paired and I'm trying to run a program on each pair. This is what they look like:
H1T1A-left.fastq.gz
H1T1A-right.fastq.gz
I can strip everything after the - to get unique names:
for d in *left*; do
echo $d | cut -d- -f1;
echo "Mapping $NAME";
done
H1T1A
H1T1B
H1T1C
H1T2A
H1T2B
But if I want to load that in to variable "NAME" so I can pass it to a program:
for d in *left*; do
NAME = echo $d | cut -d- -f1;
echo "Mapping $NAME";
done
And I get an error:
NAME: command not found
Mapping
NAME: command not found
Mapping
I'd like to be able to pass $NAME as part of a filename for each pair:
>program "$NAME"-left.file "$NAME"-right.file