sed
is a common Linux/Unix utility used to parse and transform text. Below are examples of uppercasing and lowercasing text with sed:
Uppercasing Text with sed
sed 's/[a-z]/\U&/g'
[a-z]
is the regular expression which will match lowercase letters. \U&
is used to replace these lowercase letters with the uppercase version.
Lowercasing Text with sed
sed 's/[A-Z]/\L&/g'
[A-Z]
is the regular expression which will match uppercase letters. \L&
is used to replace these uppercase letters with the lowercase version.