Let's say you have a directory containing files with extension .shtml. How would you go about renaming those to .html or .oldshtml
Here is a small script you can use to do that.
for i in `ls *.shtml` ; do mv $i ${i/shtml/html}; done
In general, do this
for i in 'ls *.<oldextension>';
do
mv $i ${i/<oldextension>/<newextension>};
done
Peace :-)
for i in $(ls *.shtml); do echo ${i/shtml/html}; done
Will work in sh and bash. The slightly shorter
for i in *.shtml; do echo ${i/shtml/html}; done
works in bash.
Expansions in the bash shell are very useful. here's an example of one I use often.
mkdir -p src/my/java/package/{client,server}
find src
src/
src/my
src/my/java
src/my/java/package
src/my/java/package/client
src/my/java/package/server
The expression "src/my/java/package/{client,server}" expands to "src/my/java/package/client src/my/java/package/server"