Software >> OS >> Unix >> Solaris >> How to rename multiple files

Example 1 ========= From ---- springerlink.txt springerlink.xml To -- springerlink_batchactivate.txt springerlink_batchactivate.xml By -- # for f in springerlink.*; do [ -s $f ] && ext=`ls -a $f | cut -f2 -d .` && mv $f springerlink_batchactivate.${ext};done Example 2 - rename all the specified S* startup scripts to NEWS* ========= # cd /etc/rc3.d # for file in S*samba S*nfs.server S*kdc.master S*kdc \ S*apache S*snmpdx S*volmgt S*dhcp; do [ -s $file ] && mv $file .NEW$file done Example 3 - to rename to something with underscore ========= # for file in log.*; do [ -s $file ] && mv $file ${file}_NEW;done curly braces enclose the variable name as it needs to append to a text beginning with _ (underscore) Example 4 - prefix log.batch* files with sciencedirect_ ========= # for f in log.batch*; do [ -s $f ] && mv $f sciencedirect_$f;done