Converting strings uppercase or lowercase in shell

If you need to convert strings to uppercase in shell, you can use tr or awk command for this.

Both of works but you can choose which one easier to remember for you.

$ cat /etc/passwd | tr '[:lower:]' '[:upper:]'

$ cat /etc/passwd | awk {'print toupper($0)'}

Similarly you can convert uppercase to lowercase too.

$ tr '[:upper:]' '[:lower:]' < /etc/passwd

$ awk {'print tolower($0)'} /etc/passwd

Note: Look at the 3 different kind of usage: pipe, file redirection and giving filename as parameter. This is the most basic feature of Linux but deep understanding of how it works greatly improve your Linux skills.