1831703 Members
2594 Online
110029 Solutions
New Discussion

Re: sort - lowercase all

 
Ravinder Singh Gill
Regular Advisor

sort - lowercase all

I want to do a sort on a couple of files. How do I specify it to ignore the case, or change all of them to lower case?
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: sort - lowercase all

Hi :

First, if you really only want the conversion of case for sorting upper and lower case values to be the same, use the '-f' switch of sort. This "folds" letters, converting all lowercase to uppercase prior to conversion. The actual data is not changed. I would think that this is really what you want.

If you truly want to convert the file to lowercase letters you could do:

# sort file |tr -s [[:upper:]] [[:lower:]]

Regards!

...JRF...
H.Merijn Brand (procura
Honored Contributor

Re: sort - lowercase all

# sort -f ....


-f: fold (ignore case in sort order)

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Sandman!
Honored Contributor

Re: sort - lowercase all

The one-liner below will lowercase the files before sorting them i.e. if I understand your question.

# awk '{print tolower($0)}' file1 file2 | sort