First, add suffix
1. Problem: The same directory has a large amount of date-named files, some of which have suffixes, some end with the point, such as 20020101.,20020102.,......,20020101.td,20020102.td ...
Requirements: Add all the suffix to the end of the point. TS
My method:
Copy Code code as follows:
#! /bin/bash
For the files in ' ls *. '
Todo
MV $files ' echo ' $filests '
Done
2. Ibid.
MV $files ${files}ts
3. Ibid.
MV $files ' $files. ts|sed ' s/\.//'
4. File =>file.txt
$files. txt $files MV
5. *.04 => *04.txt
MV $files $ (echo ${files}.txt|sed ' S/\.//1 ')
Or
MV $files ' echo ${files}.txt|sed ' S/\.//1 '
Second, change suffix (. Old =>. New)
Copy Code code as follows:
1. Rename
Rename. old. New *
2.
MV $files ${file%.old}.new
3.
MV $files ' echo $files |tr. New '
4.
MV $files ' echo $files |sed ' s/\.old/\.new/'
Third, go suffix (*.dat => *)
Copy Code code as follows:
1. MV $files ' echo $files |sed ' s/\.dat//'
2. MV $files ' echo $files |tr. DAT (4 spaces) '
Iv. prefix (re* => un*)
Copy Code code as follows:
1. MV $files un${$files #re}
2. MV $files ' echo $files | tr re un '