我有这个:
D-T4-0.txt
A-2.txt
C-3-1.txt
B-X1-3.txt
E-2-4.txt我希望点菜如下:
D, C, A, B, E我需要查看每个( .txt) D-0, C-1, A-2, B-3, E-4中的最后一个数字。
有可能吗?
发布于 2018-03-09 17:00:10
你可以在这样的管道里这样做:
# List files
ls |
# Include the sorting key in the front as well
sed -E 's/^(.*)([0-9]+)\.txt$/\2\t\1\2.txt/' |
# Sort on the sorting key
sort -n |
# Remove the sorting key
cut -f2-
# Grab the first letter
cut -c1输出:
D
C
A
B
E发布于 2018-03-09 12:58:03
for i in `awk -F- '{print $NF}' file_name |sort`;do grep -- -$i file_name;donehttps://stackoverflow.com/questions/49192127
复制相似问题