Lsd: Add support/parameter for "natural sort"

Created on 26 Jul 2020  路  2Comments  路  Source: Peltoche/lsd

Expected behavior

The "lsd" command should have a nice parameter wich naturally sorts numbers within text.

Actual behavior

The "ls" command has a nice parameter, but "lsd" hasn't:
-v natural sort of (version) numbers within text

kinbug

Most helpful comment

I could help to implement this,
but first I would like to make sure how this work because I was confused about the description (version) numbers within text

what's the meaning of the (version)?

AFAIK, -v should sort by file name in natural order, like

  1. numbers before letters
  2. number order in the natural order, like 1 2 11 21

All 2 comments

I could help to implement this,
but first I would like to make sure how this work because I was confused about the description (version) numbers within text

what's the meaning of the (version)?

AFAIK, -v should sort by file name in natural order, like

  1. numbers before letters
  2. number order in the natural order, like 1 2 11 21

Hi @zwpaper , great, that you could help :-)
Normal "ls" has "-v" option which ends up in what you said in both points:
(but I don't know why a capital letter should be sorted before a lower case and I won't mind/care about this)

root@ubuntu-cx11-02:~/temp/1# command ls -lv #h #--time-style=+%Y-%m-%d_%H:%M:%S
total 0
-rw-r--r-- 1 root root 0 Aug 12 09:12 1
-rw-r--r-- 1 root root 0 Aug 12 09:12 2
-rw-r--r-- 1 root root 0 Aug 12 09:12 3
-rw-r--r-- 1 root root 0 Aug 12 09:12 4
-rw-r--r-- 1 root root 0 Aug 12 09:12 10
-rw-r--r-- 1 root root 0 Aug 12 09:12 11
-rw-r--r-- 1 root root 0 Aug 12 09:12 12
-rw-r--r-- 1 root root 0 Aug 12 09:12 20
-rw-r--r-- 1 root root 0 Aug 12 09:12 21
-rw-r--r-- 1 root root 0 Aug 12 09:12 A
-rw-r--r-- 1 root root 0 Aug 12 09:12 B
-rw-r--r-- 1 root root 0 Aug 12 09:12 C
-rw-r--r-- 1 root root 0 Aug 12 09:12 a
-rw-r--r-- 1 root root 0 Aug 12 09:12 b
-rw-r--r-- 1 root root 0 Aug 12 09:12 c

instead of this without "-v":

root@ubuntu-cx11-02:~/temp/1# command ls -l
total 0
-rw-r--r-- 1 root root 0 Aug 12 09:12 1
-rw-r--r-- 1 root root 0 Aug 12 09:12 10
-rw-r--r-- 1 root root 0 Aug 12 09:12 11
-rw-r--r-- 1 root root 0 Aug 12 09:12 12
-rw-r--r-- 1 root root 0 Aug 12 09:12 2
-rw-r--r-- 1 root root 0 Aug 12 09:12 20
-rw-r--r-- 1 root root 0 Aug 12 09:12 21
-rw-r--r-- 1 root root 0 Aug 12 09:12 3
-rw-r--r-- 1 root root 0 Aug 12 09:12 4
-rw-r--r-- 1 root root 0 Aug 12 09:12 a
-rw-r--r-- 1 root root 0 Aug 12 09:12 A
-rw-r--r-- 1 root root 0 Aug 12 09:12 b
-rw-r--r-- 1 root root 0 Aug 12 09:12 B
-rw-r--r-- 1 root root 0 Aug 12 09:12 c
-rw-r--r-- 1 root root 0 Aug 12 09:12 C
Was this page helpful?
0 / 5 - 0 ratings

Related issues

saumyajyoti picture saumyajyoti  路  7Comments

EppO picture EppO  路  3Comments

Berrysoft picture Berrysoft  路  3Comments

rediffusion picture rediffusion  路  5Comments

spencerwooo picture spencerwooo  路  3Comments