Timeline for Sorting filenames
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 8, 2016 at 2:43 | comment | added | Jeff Schaller♦ | how do you receive the list of files? Are they files in a directory, or entries in a text file? what's the desired output: an array? printed to the screen? renamed with nicer serial numbers? per DopeGhoti's last point, if you don't know the prefix, how should it be sorted? | |
| Dec 8, 2016 at 0:41 | answer | added | Kamaraj | timeline score: 0 | |
| Dec 7, 2016 at 22:16 | answer | added | DepressedDaniel | timeline score: 0 | |
| Dec 7, 2016 at 21:16 | comment | added | DopeGhoti | If you don't know what the prefixes are going to be, it will be hard to put them in a non-lexical order, but ls * | sort -V will keep prefix-grouping. Also, the -1 in my earlier comment is not needed as a non-interactive ls has the output -1 implies in an interactive terminal. | |
| Dec 7, 2016 at 21:10 | comment | added | stacko | @DopeGhoti Sorry, I should've clarified more: the filename list's going to be updated frequently, so I'll never know what the prefix string is going to be. It might be sea, mountain, park or August, March4, June1 or whatever, but there's only one hyphen in each filename and it delimits the prefix and the number so I want to use it, but is it possible at all? | |
| Dec 7, 2016 at 20:47 | comment | added | DopeGhoti | Does $ for prefix in B A C; do ls -1 ${prefix}* | sort -V ; done do what you want for your actual use-case? It seems to work for the sample set you have provided. | |
| Dec 7, 2016 at 20:39 | history | asked | stacko | CC BY-SA 3.0 |