Convert file contents to lower case

If your input only contains ASCII characters, you could use tr like:

tr A-Z a-z < input 

or (less easy to remember and type IMO; but not limited to ASCII latin letters, though in some implementations including GNU tr, still limited to single-byte characters, so in UTF-8 locales, still limited to ASCII letters):

tr '[:upper:]' '[:lower:]' < input

if you have to use sed:

sed 's/.*/\L&/g' < input

(here assuming the GNU implementation).

With POSIX sed, you'd need to specify all the transliterations and then you can choose which letters you want to convert:

sed 'y/AǼBCΓDEFGH.../aǽbcγdefgh.../' < input

With awk:

awk '{print tolower($0)}' < input

Using vim, it's super simple:

$ vim filename
gg0guGZZ

Opens the file, gg goes to the first line, 0, first column. With guG, lowers the case of all the characters until the bottom of the file. ZZ saves and exits.

It should handle just about anything you throw at it; it'll ignore numbers, it'll handle non ASCII.

If you wanted to do the opposite, turn the lower cased letters into upper case, swap the u out for a U: gg0gUGZZ and you're set.


I like dd for this, myself.

<<\IN LC_ALL=C 2<>/dev/null \
dd conv=lcase
hi
Jigar 
GANDHI
jiga
IN

...gets...

hi
jigar
ghandi
jiga

The LC_ALL=C is to protect any multibytes in input - though any multibyte capitals will not be converted. The same is true for (GNU) tr - both apps are prone to input mangling in any non-C locale. iconv can be combined with either for a comprehensive solution.

The 2>/dev/null redirect discards dd's default status report - and its stderr. Without it dd would follow completion of a job like the above w/ printing information like how many bytes were processed and etc.