Skip to main content
removed unnecessary $ to prevent issue with copy paste. and commented the output part.
Source Link
Mohammad Faisal
  • 5.9k
  • 15
  • 73
  • 123

Bash 5.1 provides a straight forward way to do this with the L parameter transformation:

${var@L}

So for example you can say:

$ v="heLLo"
$ echo "${v@L}"
hello
v="heLLo"
echo "${v@L}"
# hello

You can also do uppercase with U:

$ v="hello"
$ echo "${v@U}"
HELLO
v="hello"
echo "${v@U}"
# HELLO

And uppercase the first letter with u:

$ v="hello"
$ echo "${v@u}"
Hello
v="hello"
echo "${v@u}"
# Hello

Bash 5.1 provides a straight forward way to do this with the L parameter transformation:

${var@L}

So for example you can say:

$ v="heLLo"
$ echo "${v@L}"
hello

You can also do uppercase with U:

$ v="hello"
$ echo "${v@U}"
HELLO

And uppercase the first letter with u:

$ v="hello"
$ echo "${v@u}"
Hello

Bash 5.1 provides a straight forward way to do this with the L parameter transformation:

${var@L}

So for example you can say:

v="heLLo"
echo "${v@L}"
# hello

You can also do uppercase with U:

v="hello"
echo "${v@U}"
# HELLO

And uppercase the first letter with u:

v="hello"
echo "${v@u}"
# Hello
Source Link
fedorqui
  • 285.3k
  • 105
  • 579
  • 617

Bash 5.1 provides a straight forward way to do this with the L parameter transformation:

${var@L}

So for example you can say:

$ v="heLLo"
$ echo "${v@L}"
hello

You can also do uppercase with U:

$ v="hello"
$ echo "${v@U}"
HELLO

And uppercase the first letter with u:

$ v="hello"
$ echo "${v@u}"
Hello