日期:2014-05-16 浏览次数:20813 次
[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]$ ll total 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/sh ls -1 | while read name; do new_name=`echo $name | sed -r 's/^.*-.*-(.*\.dat)$/\1/g'`; mv $name $new_name; done