I want to get a sorted list of files. Files have the following naming convention:
DATENUMBER.txt (no spaces).
For example, file 3 on 2015-12-09 as follows: 201512093.txt
The version sort ls option doesn't help me:
ls -v: 201512183.txt 201512184.txt 201512188.txt 201512191.txt 201512195.txt 201512199.txt 2015121810.txt 2015121813.txt 2015121910.txt 2015121911.txt 2015121932.txt
sort -V , --key=1.[number] doesn't work either , since I have a different file length.
Since I don't have a division between date and number, sort -t, -k doesn't work either.
As you can see, I need to sort the file list by the first 8 characters in the file names and after that by the other part of the line .
Expected Result:
201512183.txt 201512184.txt 201512188.txt 2015121810.txt 2015121813.txt 201512191.txt 201512195.txt 201512199.txt 2015121910.txt 2015121911.txt 2015121932.txt
How can I do this ( linux with bash )? Thanks.
source share