0

Upper, Lower Case and Trim

Posted March 3rd, 2009. Filed under Sharing elmu

Here is simple example how to set upper and lower case in shell script :

var="sAmplE teST"
var_ucase=`echo ${var} | tr [a-z] [A-Z]`
var_lcase=`echo ${var} | tr [A-Z] [a-z]`
echo "Upper Case : ${var_ucase}"
echo "Lower Case : ${var_lcase}"

Here is example how to trim variable in shell script :

var=" 322245 "
var_trim=`echo ${var} | sed 's/^ *\(.*\) *$/\1/'`
echo "Trimmed var : ${var_trim}"
If you have enjoyed this entry. Please feel free to bookmark it using your favorite social bookmarking site

Leave a Comment