I have the below list of filesaro_tty-mIF-45875564pmo_optaro_tty-mIF-45875664pmo_optaro_tty-mIF-45875964pmo_optaro_tty-mIF-45875514pmo_optaro_tty-mIF-45875524pmo_optthat I need to rename toaro_tty-mImpFRA-45875564pmo_optaro_tty-mImpFRA-45875664pmo_optaro_tty-mImpFRA-45875964pmo_optaro_tty-mImpFRA-45875514pmo_optaro_tty-mImpFRA-45875524pmo_optPlease help me out.
How to rename multiple files in single command or script in Unix?
linux;shell script;rename
Most standard shells provide a way to do simple text substitution within shell variables. http://tldp.org/LDP/abs/html/parameter-substitution.html explains as follows:${var/Pattern/Replacement}First match of Pattern, within var replaced with Replacement.So use this script to loop through all the appropriate files and rename each of them:for file in aro_tty-mIF-*_optdo    mv -i ${file} ${file/-mIF-/-mImpFRA-}doneI have added a -i option so you have the chance to confirm each renaming operation. As always, you should make a backup of all your files before doing any large amount of renaming or deleting.