Dave's Brain

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:]')

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.