I have below list of files in a folder. Every file name has date and time (yyyymmdd_hhmm) in it. The last 3 characters are the sequence number which resets at 999 and after this max sequence, the sequence will again start from 001.
node55_20200420_1755_995
node55_20200420_1756_998
node55_20200420_1755_996
node55_20200420_1757_999
node55_20200420_1756_997
node55_20200420_1757_001
node55_20200420_1758_002
node55_20200420_1758_003
When I use command
ls node* | sort
I get below get output. I want sequence 001 after the 999. The command works fine except when sequence reset appears. Any idea how to handle it ?
Actual output
node55_20200420_1755_995
node55_20200420_1755_996
node55_20200420_1756_997
node55_20200420_1756_998
node55_20200420_1757_001
node55_20200420_1757_999
node55_20200420_1758_002
node55_20200420_1758_003
Desired output
node55_20200420_1755_995
node55_20200420_1755_996
node55_20200420_1756_997
node55_20200420_1756_998
node55_20200420_1757_999
node55_20200420_1757_001
node55_20200420_1758_002
node55_20200420_1758_003
20200420_1757_001to20200420_1757_999then, if20200420_1757_999should sort before20200420_1757_001? It would be better to sort according to modification timestamp, if the resolution of that was good enough, maybe something likels -tr? What shell are you using?1757_999be sorted before1757_001? And if 999 should be before 001, then shouldn't 003 also be before 002?