BASH: Convert Uppercase to Lowercase letters

Vivek Gite on nixCraft suggests tr to tranform uppercase letters in the textfile input.txt to lowercase and output the transformed text to output.txt.

tr '[:upper:]' '[:lower:]' output.txt

I needed to clean up a messy old scriptfile where I lost track of my variable naming convention.

Very useful indeed 🙂

Advertisements

Replacing capitals with normal letters using SED

Needed to change CAPITAL variable names to normal in a long SQL-syntax file. Sourceforge had a way to do it with SED.

GSED 4.+ supports the \L& and \U& switches to transform everything to lowercase or uppercase respectively:

sed 's/MyRegExp/\L&/g'

changes the regular expression MyRegExp into lowercase.