Skip to main content
removed irrelevant tags, added relevant ones
Link
cas
  • 84.4k
  • 9
  • 136
  • 205
Source Link

linux - setting order in which files are read or output with utilities (sorting)

I'm having issues with programs reading files in the wrong order, and also outputting in an undesirable order with utilities such as ls.

I've tried some of the LC_COLLATE options, but none of them fit the preference I seek, so I figured there must be something more I can do.

Examples of commands producing wrong order:

user@host: /home/user/Video $ mpv *.mkv

There are 150 files in /home/user/Video, and here are the first 12 a command from a program like mpv *.mkv would read:

TVSeriesName - 01.mkv
TVSeriesName - 02.mkv
TVSeriesName - 03.mkv
TVSeriesName - 04.mkv
TVSeriesName - 05.mkv
TVSeriesName - 06.mkv
TVSeriesName - 07.mkv
TVSeriesName - 08.mkv
TVSeriesName - 09.mkv
TVSeriesName - 10.mkv
TVSeriesName - 100.mkv
TVSeriesName - 101.mkv

It's reading 100 before it reads 11, even with leading zero.

Ideally, it should read them in the correct 1-150 order even without a leading zero.

What I want is to have a universal order in which files are read and sorted that resembles the default of the ranger file manager.

Example:

.1-hiddendir/
.2-hiddendir/
.a-hiddendir/
.b-hiddendir/
.C-hiddendir/
.d-hiddendir/
.E-hiddendir/
1-dir/
2-dir/
A-dir/
b-dir/
c-dir/
D-dir/
.1-dotfile
.2-dotfile
.a-dotfile
.b-dotfile
.C-dotfile
1-file
2-file
a-file
B-file
c-file

OS: Arch Linux, FS: ext4

What can I do with environment settings, or anything, in a Linux distribution to achieve this?