case conversion in bash script??



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

I am writing a bash script.

Lets say,


Hate these ads?

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'



Comments /Forum/anonymous39.html


Wed Aug 16 09:59:26 2006: Subject:   TonyLawrence
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: Subject:   anonymous
(your comments go here)



One can also use awk for the same:-

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

~rakesh


Add your comments
cartoon
Need eyes on the ground at your customer's site?
Installation and light training Boston and New England
Reliable and experienced, punctual and professional.


Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner


Views for this page
Today This Week This Month This Year  Overall
56621,973 10,175

/Forum/anonymous39.html copyright August 2006 anonymous All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

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. We appreciate comments and article submissions.

Publishing your articles here

More:
       - Forum
       - Shell




Unix/Linux Consultants

Your ad here - $24.00 yearly!

http://www.cleverminds.net Need expert advice? Want a second opinion? CleverMinds is a one-stop-shop for a wide range of technology solutions. We support Unix, Linux, SCO as well as CMS, ecom, blogs, podcasts, search engines consulting and more. Contact us at web2.0@cleverminds.net 0r (617) 894-1282


http://thatitguy.com Business networking servers, Linux and Unix experts. In business since 1997! Windows and Exchange to Samba and Scalix migration experts.


http://www.m3ipinc.com Security, firewalls, ids, audits, vulnerability assesments, BS7799, HIPAA, GLB, incident handling









Change Congress


Related Posts