Sunday, 8 February 2015

Uppercase and Lowercase Conversion - Bash Style

After a long long time, I am back with this short post to convert case of strings in bash. While you might have been using tr (Like I did for a while) for this purpose, bash 4 has a built-in way for the case conversion. Withour further ado, here is a session
$ x="samar"

$ echo "${x^}"
Samar

$ echo "${x^^}"
SAMAR

$ y="${x^^}"

$ echo $y
SAMAR

$ echo "${y,}"
sAMAR

$ echo "${y,,}"
samar


I hope this helps ;)


Read more...