linux sort 命令
1、目录下文件
# ls -l
release.100.csv release.101.csv release.102.csv release.103.csv release.104.csv release.105.csv release.106.csv release.107.csv release.108.csv release.109.csv release.110.csv release.86.csv release.87.csv release.88.csv release.89.csv release.90.csv release.96.csv release.97.csv release.98.csv release.99.csv
2、重新排列
ls * | sort -n -t . -k 2
解释:
-n 按照数字排排序
-r 反向
-t 分割(文件名)
-k 2 第k(2)位置的数据排列
ls * | sort -n -t . -k 2 release.86.csv release.87.csv release.88.csv release.89.csv release.90.csv release.96.csv release.97.csv release.98.csv release.99.csv release.100.csv release.101.csv release.102.csv release.103.csv release.104.csv release.105.csv release.106.csv release.107.csv release.108.csv release.109.csv release.110.csv