How to convert filenames or text to lowercase on the shell

Wednesday, September 2, 2009 posted by admin

There is no simple tolower command on the bash, but with a little shell script you can convert uppercase characters to lowercase. The script uses the tr command internally for converting the chars.

Create a shell script with the name tolower:

vi /usr/local/bin/tolower

and enter the following content:

#!/bin/sh echo $1 | tr '[:upper:]' '[:lower:]' Then make the script executable: <p class="command">chmod +x /usr/local/bin/tolower

An test it by executing this command on the shell:

tolower "Thats a Test"

will convert the string to lowercase and show the result on the shell:

thats a test

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Twitter
  • FriendFeed
  • MisterWong
  • StumbleUpon


Leave a Reply