# # case conversion in bash script??
APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

case conversion in bash script??

I've removed advertising from most of this site and will eventually clean up the few pages where it remains.

While not terribly expensive to maintain, this does cost me something. If I don't get enough donations to cover that expense, I will be shutting the site down in early 2020.

If you found something useful today, please consider a small donation.



Some material is very old and may be incorrect today

© August 2006 anonymous


Author: anonymous
Date: Wed Aug 16 07:34:38 2006
Subject: case conversion in bash script??

I am writing a bash script.

Lets say,

VAR="Rakesh"

Now I want to convert the content of VAR ($VAR) to lowercase. How can I do in bash.

i.e if I echo $VAR, I should get 'rakesh' not 'Rakesh'


If you found something useful today, please consider a small donation.



Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> case conversion in bash script??

4 comments


Inexpensive and informative Apple related e-books:

iOS 8: A Take Control Crash Course

Sierra: A Take Control Crash Course

Take control of Apple TV, Second Edition

Take Control of Pages

Photos: A Take Control Crash Course





More Articles by © anonymous







Wed Aug 16 09:59:26 2006: 2397   TonyLawrence

gravatar
new=`echo $old | tr '[A-Z' '[a-z]'`

In other words, it has nothing to do with Bash: you could do this in any shell that allows backtick or some other way to accept the output of external cammands.

new=$(echo $old | tr '[A-Z' '[a-z]')

is a "Bash" solution, but the work is still done by "tr".



Wed Aug 16 13:25:15 2006: 2398   anonymous




One can also use awk for the same:-

new = echo $old | awk '{print tolower($0)}'

~rakesh






Mon Jun 8 07:10:38 2009: 6466   anonymous

gravatar
little correction
new=$(echo $old | tr '[A-Z]' '[a-z]')
you missed the ']'

------------------------


Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us


Printer Friendly Version





We are questioning more than the philosophy behind our dependence upon limited and limiting systems. We question the power structures that have grown up around such systems (Frank Herbert).




Linux posts

Troubleshooting posts


This post tagged:

Forum

Scripting

Shell



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode