I would like to build a little helper function that can deal with fastq.gz and fastq.bz2 files.
I want to merge zcat and bzcat into one transparent function which can be used on both sorts of files:
zbzcat example.fastq.gz
zbzcat example.fastq.bz2
zbzcat() {
file=`echo $1 | `
## Not working
ext=${file##*/};
if [ ext == "fastq.gz" ]; then
exec gzip -cd "$@"
else
exec bzip -cd "$@"
fi
}
The extension extraction is not working correctly. Are you aware of other solutions