简体   繁体   中英

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....)

Thanks

使用版本排序:

find -name '*.txt' | sort -V | tail -1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM