Browse - Programming Tips - How can I change uppercase to lowercase in a bash script.

Date: 2016may1
Language: bash

Q.  How can I change uppercase to lowercase in a bash script.

A.  Use the tr (translate) command:

tr '[:upper:]' '[:lower:]' <filein >fileout
The older style (that still works):
tr '[A-Z]' '[a-z]' <filein >fileout
This is slightly shorted but not quite as clear. To make the contents of a bash variable lowercase:
myvar=$(echo $myvar | tr '[:upper:]' '[:lower:]')