Converting upper/lower case on the command line in Linux

A quick and simple way to convert upper/lower case on the command line in Linux is to use the “tr” (translate) utility.

To convert uppercase to lowercase:

tr [A-Z] [a-z]

To convert lowercase to uppercase:

tr [a-z] [A-Z]

And in a shell script:

VALUE="A Mixed Case String"
UPPER=`echo $VALUE | tr [a-z] [A-Z]`
LOWER=`echo $VALUE | tr [A-Z] [a-z]`

Leave a comment

  • Tags

  • Categories

  • Need Code Written?

  • Need a Coding Job?

  • Archives