I am trying to extract parts of a filename, where I want to extract everything after the first _ and I have found a working solution, see below
file=22NGS71294_S191_R1_001.fastq.gz
echo $file
22NGS71294_S191_R1_001.fastq.gz
echo ${file#*[_ ]}
S191_R1_001.fastq.gz
but, when I use wildcards, it stops working
file2=*R1*
echo $file2
22NGS71294_S191_R1_001.fastq.gz
echo ${file2#*[_ ]}
22NGS71294_S191_R1_001.fastq.gz
I have no idea why this is not working, as the echo command of $file and $file2 gives the exact same results. Could someone please explain this behaviour?