1

How to sort lowercase to uppercase

For example

Dir3 dir1 dir2 dir3

In my case

Dir3 dir1 dir2 dir3

sort -f
dir1 dir2 Dir3 dir3

But I want

dir1 dir2 dir3 Dir3

How to sort lowercase to uppercase?

agc
  • 7,973
  • 2
  • 29
  • 50
Pyo
  • 21
  • 2
  • 1
    Try `LANG=en_US.utf8 sort -f ...`. The locale has an influence on the sort order. `en_US.utf8` will give you the desired results – hek2mgl May 09 '20 at 05:31
  • `ls | env LC_ALL=en_US sort -f` and `ls | env LC_ALL= sort -f` gives different results for me, see this question https://stackoverflow.com/questions/28881/why-doesnt-sort-sort-the-same-on-every-machine – Vadik Sirekanyan May 09 '20 at 05:33
  • I tried 2 cases and see the question, but, results are same.... – Pyo May 09 '20 at 06:56
  • what command are you sorting ? ls ? dir ? –  May 12 '20 at 14:18

1 Answers1

0

Something like this should solve your problem:

$ echo -e "Dir3\ndir1\ndir2\ndir3" | sort
dir1
dir2
dir3
Dir3
Dharman
  • 30,962
  • 25
  • 85
  • 135
lucasgrvarela
  • 351
  • 1
  • 4
  • 9