现在有以数字命名的文件如下:
-rw-r--r-- 1 root root 0 Mar 15 15:45 12.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 13.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 14.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 15.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 16.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 17.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 18.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 19.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 1.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 2.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 3.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 4.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 5.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 6.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 7.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 8.txt
-rw-r--r-- 1 root root 0 Mar 15 15:45 9.txt
想将所有文件重新命名,就是在原来的文件名前加一个a变成a1.txt这类的,
如果在数字连续的情况下,可以用FOR循环来实现:
[root@centos_7_1 dd]# i=1; for x in *; do mv $x a$i.txt;let i=i+1; done
但是现在数字文件名不连续,该怎么做?