Objective: To rename several files in batches. These files have common features, such as having the same letters or having no common features. to rename these files in a unified manner, modify the characters at the same position.
1. I want to change the first letter of their names to "q", and the others will not change.
[Root @ pps mailqueue] # for I in 'LS'; do mv-f $ I 'echo $ I | sed's/^./q/''; done ----------------------------------------
Or write a script to make it clearer: for file in 'LS'
Do
Newfile = 'echo $ I | sed's/^./q /''
Mv $ file $ newfile
Done
----------------------------------------
2. Change the first five letters to zhaozh.
[Root @ pps mailqueue] # for I in 'LS'; do mv-f $ I 'echo $ I | sed's/^ ..... /zhaozh/''; done
3. Change the last five letters to "snail Il ".[Root @ pps mailqueue] # for I in 'LS'; do mv-f $ I 'echo $ I | sed's /..... $/snail il/''; done
4. Add _ hoho _
[Root @ pps mailqueue] # for I in 'LS'; do mv-f $ I 'echo "_ hoho _" $ I '; done
5. Change all lowercase letters to uppercase letters.[Root @ pps mailqueue] # for I in 'LS'; do mv-f $ I 'echo $ I | tr a-z A-Z '; done
Alas, five examples are given. In the end, the idea of "for loop + combined command processing" is used to batch rename objects.