In Linux, renaming files in batches involves changing a letter, changing some connected letters, changing letters at some locations, adding certain letters at the beginning, or changing the case sensitivity of letters. After completing the five methods, the Linux batch rename is basically solved.
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
In the preceding section, the Linux batch rename method is completed in step 5.
- Detailed command 1 for running Linux background)
- Brief Introduction to Linux kernel Security Intrusion Detection System
- Detailed analysis of Linux Firewall Configuration
- Differences between Linux and Unix
- About the Linux upload and download commands and how to set the path