bash shell
method 1
# get the base name of a file f=twist_ip.fastq.gz base=`basename $f .fastq.gz` echo $base
method 2
More modern, and placing the file variable in quotes will survive files with spaces in the name.
# the modern way f=twist_ip.fastq.gz base=$(basename "$f" .fastq.gz) echo $base