Howto: convert string to all uppercase

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search

To easily convert a text string to UPPERCASE we use the built-in bash commands:

  • echo
  • tr
$ echo convert this to uppercase | tr [a-z] [A-Z]
CONVERT THIS TO UPPERCASE
$

To convert a complete file we use the '<' redirect:

$ tr [a-z] [A-Z] < convert_to_uppercase.txt
CONVERT THIS TO UPPERCASE
$