用awk的一个批量改名问题
我这边有大量的文件,格式均为2012XXXXXXXX-XXXXXX-bXXXXXX.dat的文件,我要做的是将这些文件名改名为bXXXXXXXX.dat,批量哦,请问这个脚本要怎么写,求提示啊,文件模板:201204010000-000000-b044831.dat
[解决办法]
- PHP code
[User:root Time:18:33:38 Path:/home/liangdong/shell]$ ./test.sh mv: `test.sh' and `test.sh' are the same file[User:root Time:18:33:39 Path:/home/liangdong/shell]$ lltotal 4-rw-r--r--. 1 root root 0 May 28 18:30 b044831.dat-rw-r--r--. 1 root root 0 May 28 18:30 b044832.dat-rw-r--r--. 1 root root 0 May 28 18:30 b044833.dat-rwxr--r--. 1 liangdong liangdong 125 May 28 18:33 test.sh[User:root Time:18:33:40 Path:/home/liangdong/shell]$ cat test.sh #!/bin/shls -1 | while read name; do new_name=`echo $name | sed -r 's/^.*-.*-(.*\.dat)$/\1/g'`; mv $name $new_name;done