I have a groups of files in a folder. Each group is identified by characters 3-6 in the file name. I want to read in all the files of the group, count how many files there are, and then assign the file name to a variable made up of some letters and the counter. e.g. FILENAME$COUNTER. My code is almost working but there seems to be a problem with assigning the counter to the variable name.
I get this error for the line with code FILE$COUNTER=$i
line 12: FILE1=5_lib1ln1_BWA_ddrot_testonl_pe12.bam: command not found
This is exactly what I wanted for the variable name and assignment, but its saying command not found. I'm not sure why there is a command not found.
#!/bin/bash
## All files from the same group have the same LIB
LIB='lib1'
COUNTER=0
for i in 5_*.bam
do
SAMPLIB=`echo $i | cut -c 3-6`
if [ "$LIB" = "$SAMPLIB" ]; then
let COUNTER++
FILE$COUNTER=$i
fi
NUMFILES=$COUNTER
done