0

I already found this answer Sorting a file with integer in parentheses with no space but it doesn't cover my specifics.

I thought ls | sort -k 7,8.2g should work, but I get this instead:

A B C D E F 27 (10)
A B C D E F 27 (11)
A B C D E F 27 (12)
A B C D E F 27 (13)
A B C D E F 27 (14)
A B C D E F 27 (15)
A B C D E F 27 (16)
A B C D E F 27 (17)
A B C D E F 27 (18)
A B C D E F 27 (19)
A B C D E F 27 (1)
A B C D E F 27 (20)
A B C D E F 27 (21)
...
A B C D E F 28 (10)
A B C D E F 28 (11)
...

Strangely, sort -k 8.3g does group the (1) and then (2)... (9), (10)... but sort -k 7,8.3g does not sort by field 7 and then by field 8.

I want:

A B C D E F 27 (1)
A B C D E F 27 (2)
A B C D E F 27 (3)
...
A B C D E F 27 (9)
A B C D E F 27 (10)
A B C D E F 27 (11)
...
A B C D E F 27 (19)
A B C D E F 27 (20)
A B C D E F 27 (21)
...
A B C D E F 28 (1)
A B C D E F 28 (2)
...

jrwren
  • 103
  • 1
  • 6

1 Answers1

0

UGH... after clicking the sort tag and reading a few questions, I stumbled up on the "weird sort behavior" questions.

Unexpected sort order in en_US.UTF-8 locale

It sorts exactly how I want if I use LC_ALL=C

jrwren
  • 103
  • 1
  • 6