I have a number of tiff files named:
sw.001.tif sw.002.tif ...
and I want to remove the
.tif at the end of each of the files. How can I use the
rename command to do this?
rename (as typically found on Debian where it's also called
prename), or this derivative (
rename package on Debian):
rename 's/\.tif$//' *.tif
rename (as typically found on Red Hat,
rename.ul on Debian):
rename -- .tif '' *.tif
(note that that one would rename
rename -- .oldext .newext *.oldext
This substitutes the old extension with the new one. To simply remove the extension you can explicitly pass in an empty string as an argument.
rename -- .gz.tmp '' *.gz.tmp
With the above command all files with
.gz.tmp extension in the current folder will be renamed to
Refer to the article : Linux: remove file extensions for multiple files for details.