uppercase first character in a variable with bash
One way with bash (version 4+):
foo=bar
echo "${foo^}"
prints:
Bar
$ foo="bar";
$ foo=`echo ${foo:0:1} | tr '[a-z]' '[A-Z]'`${foo:1}
$ echo $foo
Bar
One way with sed
:
echo "$(echo "$foo" | sed 's/.*/\u&/')"
Prints:
Bar
foo="$(tr '[:lower:]' '[:upper:]' <<< ${foo:0:1})${foo:1}"