Bash Tip! Renaming files using Bash string operations
To rename all html files in a particular directory to shtml files, use the following loop:
for file in *.html
do
mv ${file} ${file%%.html}.shtml
done
This uses the ${variable%%match} format which strips the longest match from the end of the variable.
This entry was posted
on Wednesday, January 6th, 2010 at 10:47 pm and is filed under Linux, Open Source Software, Tip of the day!.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.