[root@localhost test]# pwd
/data/soft/test
[root@localhost test]# ls
10.txt 1.txt 2.tx 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt脚本内容:
dir="/data/soft/test/*"
for i in $dir;dob=`echo "$i" | tr -cd "[0-9]"`echo "$b"
done运行结果:
[root@localhost ~]# sh test.sh
10
1
2
2
3
4
5
6
7
8
9