Thursday, February 27, 2020

Converting between uppercase and lowercase on the Linux command line

There are many ways to change text on the Linux command line from lowercase to uppercase and vice versa. In fact, you have an impressive set of commands to choose from. This post examines some of the best commands for the job and how you can get them to do just what you want.

Using tr

The tr (translate) command is one of the easiest to use on the command line or within a script. If you have a string that you want to be sure is in uppercase, you just pass it through a tr command like this:

$ echo Hello There | tr [:lower:] [:upper:]

Below is an example of using this kind of command in a script when you want to be sure that all of the text that is added to a file is in uppercase for consistency:

To read this article in full, please click here

Thanks to Sandra Henry-Stocker (see source)

No comments:

Post a Comment