2008年12月27日星期六

目录下文件按数字顺序集体重命名(awk)

bbskuang@ubuntu:~$ ls | awk '{print "mv "$1, NR".txt"}' | sh
mv: `1.txt' and `1.txt' are the same file

bbskuang@ubuntu:~$ ls
1.txt 11.txt 13.txt 15.txt 17.txt 19.txt 3.txt 5.txt 7.txt 9.txt
10.txt 12.txt 14.txt 16.txt 18.txt 20.txt 4.txt 6.txt 8.txt

bbskuang@ubuntu:~$ ls -al



http://freebsd.chinaunix.net/bbs/thread-1340676-1-1.html

没有评论: