Verified Environment
Version | |
---|---|
OS | Ubuntu 20.04.5 LTS |
bash | GNU bash, version 5.0.17(1)-release (aarch64-unknown-linux-gnu) |
What to do
The ‘^’ operator converts lowercase letters matching pattern to uppercase; the ‘,’ operator converts matching uppercase letters to lowercase. The ‘^^’ and ‘,,’ expansions convert each matched character in the expanded value;
https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion
val="ABC"
echo ${val,,}
val="abc"
echo ${val^^}
Verified Environment
Version | |
---|---|
OS | Ubuntu 20.04.5 LTS |
awk | mawk 1.3.4 20200120 |
What to do
echo ABC | awk '{print tolower($0)}'
echo abc | awk '{print toupper($0)}'
Verified Environment
Version | |
---|---|
OS | Ubuntu 20.04.5 LTS |
sed | sed (GNU sed) 4.7 |
What to do
\L Turn the replacement to lowercase until a \U or \E is found,
\U Turn the replacement to uppercase until a \L or \E is found,
https://www.gnu.org/software/sed/manual/sed.html#The-_0022s_0022-Command
echo ABC | sed -e 's/\(.*\)/\L\1/'
echo abc | sed -e 's/\(.*\)/\U\1/'
Verified Environment
Version | |
---|---|
OS | Ubuntu 20.04.5 LTS |
tr | tr (GNU coreutils) 8.30 |
What to do
[:lower:] all lower case letters
[:upper:] all upper case letters
https://man7.org/linux/man-pages/man1/tr.1.html
echo ABC | tr '[:upper:]' '[:lower:]'
echo abc | tr '[:lower:]' '[:upper:]'