Convert text to upper-case or lower-case

There are more than a couple of ways to convert a string with upper-case letters to lower-case and vice-versa in Linux, here are my favorite two:

awk

echo "TEXT WITH CAPS-LOCK ON" | awk '{print tolower($0)}'
text with caps-lock on
 
echo "text with caps-lock off" | awk '{print toupper($0)}'
TEXT WITH CAPS-LOCK OFF

dd

echo "TEXT WITH CAPS-LOCK ON" > upperText; dd if=upperText of=lowerText conv=lcase; cat lowerText
0+1 records in
0+1 records out
23 bytes (23 B) copied, 2.1e-05 seconds, 1.1 MB/s
text with caps-lock on
 
echo "text with caps-lock off" > lowerText; dd if=lowerText of=upperText conv=ucase; cat upperText
0+1 records in
0+1 records out
24 bytes (24 B) copied, 3.4e-05 seconds, 706 kB/s
TEXT WITH CAPS-LOCK OFF

Leave a Reply

Page optimized by WP Minify WordPress Plugin