[英]bash script - getting highest file name number from folder
I tries a lot of whys to solve the following problem without a solution :( 我尝试了很多为什么没有解决方案来解决以下问题:(
I have a folder which contains files with the following name pattern: 我有一个文件夹,其中包含具有以下名称模式的文件:
number_name.txt
for example: 例如:
0_test.txt
17_test.txt
39_test.txt
99_test.txt
101_test.txt
17_test.txt
I need to get the file name which contain the max prefix number. 我需要获取包含最大前缀号的文件名。
(when I compare the strings, I'm getting that "99_test.txt" is the highest which is not true....) (当我比较字符串时,我得到的是“99_test.txt”是最高的,这是不正确的....)
Thanks 谢谢
使用版本排序:
find -name '*.txt' | sort -V | tail -1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.