< BACK

Bash tips, tricks and code snippets

Uppercase a variable’s first character

Lifted from this posting, using tr and parameter expansion, this can be achieved thus:

str="this string"
str="$(tr '[:lower:]' '[:upper:]' <<< ${str:0:1})${str:1}"
echo $str // This string