Thursday, December 16, 2010

How to convert strings to lower or upper case in Bash script

To lower case:

upper="YES"
lower="$(echo $upper | tr [:upper:] [:lower:])"
echo "$upper > $lower"

To upper case:

lower="no"
upper="$(echo $lower | tr [:lower:] [:upper:])"
echo "$lower > $upper"

No comments:

Post a Comment