CentOS 6.6 MV Rename are not meeting the requirements
All file name formats are as follows:
[[email protected]] [1442146016999] [<[email Protected]>] [[email protected]] [You have successfully booked "Huashan Yuhua Hotel"].html
You need to change "[" to "# # #" and delete the "[" and "]"
1. First Escape ls | Sed ' s/@/\\@/g ' | Sed ' s/\[/\\[/g ' | sed ' s/</\\</g ' | sed ' s/>/\\>/g ' | sed ' s/\]/\\]/g ' | Sed ' s/(/\\ (/g ' | sed ' s/)/\\)/g '
2. Process and rename sed ' s/\\\[\ (. *\) \\\]\\\[\ (. *\) \\\]\\\[\ (. *\) \\\]\\\[\ (. *\) \\\]\\\[\ (. *\) \\\]/MV &.html \1###\2###\3# ##\4###\5.html/e '
The two parts are combined together.
Note: 1, before the second step must be the file name of all the special characters escaped (the first step is to do this)
2. The "&" in the second step of the MV represents the matched string
3. SED usage here is sed ' s/*/mv & */e '
4, the second step of the MV "\1 \2 \3" and so on behalf of the front of the parentheses in the content
Linux Batch file renaming