compress --> gzip

I have hundreds of ".Z" files that I need to uncompress and gzip. I'm not sure how to handle this in a 'for loop'. I can get the uncompress part, but I'm not sure how to strip the .Z off the filename for the gzip step. Is it possible to pipe the output of uncompress to gzip?

for file in *.Z

BASE=`basename $file .Z`
uncompress $file
gzip $BASE


Thanks PxT :slight_smile: I didn't realize that a "basename" command exists.