Search:  

 
 
   All ForumsHot TopicsGallery






how-to block ads


 
Forums » Tech and Talk » OS and Software » All Things Unix » Make variables uppercase in bash.
Search Topic:
Share Topic:
RSS topic:
toggle:
flat / full
normal / watch
Posting:
Post a:
Post a:
Sendmail Config... »
« Grub Question.  
AuthorAll Replies


Maxo
Your tax dollars at work.
Premium,VIP
join:2002-11-04
Tallahassee, FL
clubs:
reply to deblin
Re: Make variables uppercase in bash.

All the examples of tr that I saw had to take files. I didn't think about using pipes. I think that should work. I'll try it and let you know.


deblin
Dark Side of the Moon
Premium,MVM
join:2001-09-01
Middletown, DE
oh ok! cool, should do the trick.


Maxo
Your tax dollars at work.
Premium,VIP
join:2002-11-04
Tallahassee, FL
clubs:

I think I may need to be a little more specific. We are writing a bash script that reads some stuff and builds a control file for Oracle's sqlldr, and then we execute sqlldr with the build control file. Our code looks much like this:

The myAmicFiles just looks like this:
amici.990120
amici.990220
amico.990520
amico.990620

I need the i or o to be uppercase.

--
"Padre, nobody said war was fun now bowl!" - Sherman T Potter

»www.cafepress.com/maxolasersquad

»maxolasersquad.com/

»maxolasersquad.com/network/ My DSL Network Guide

»myspace.com/mlsquad


deblin
Dark Side of the Moon
Premium,MVM
join:2001-09-01
Middletown, DE
Looks like a good place for a perl script.


Maxo
Your tax dollars at work.
Premium,VIP
join:2002-11-04
Tallahassee, FL
clubs:

said by deblin See Profile :

Looks like a good place for a perl script.
If you knew what Perl and I had been through the last two and a half weeks you wouldn't joke like that.


deblin
Dark Side of the Moon
Premium,MVM
join:2001-09-01
Middletown, DE

said by Maxo See Profile :

said by deblin See Profile :

Looks like a good place for a perl script.
If you knew what Perl and I had been through the last two and a half weeks you wouldn't joke like that.
heh! ok, well let me take a look.
--
He who is not contented with what he has, would not be contented with what he would like to have. -Socrates


deblin
Dark Side of the Moon
Premium,MVM
join:2001-09-01
Middletown, DE

reply to Maxo
So in this line:

quote:
echo " column3 CONSTANT '" ${LINE:4:1} | tr 'a-z' 'A-Z' "'," >> file_loader.ctl

You want just the capital letter?

E.g. for LINE = amico.990120 you want just the O?

Or do you want amicO.990120 ?
--
He who is not contented with what he has, would not be contented with what he would like to have. -Socrates


deblin
Dark Side of the Moon
Premium,MVM
join:2001-09-01
Middletown, DE

reply to Maxo
Probably the easiest thing to do would be to set a variable for the letter first, then just use that variable.

e.g instead of:

bash code:
echo " column3 CONSTANT '" ${LINE:4:1} | tr 'a-z' 'A-Z' "'," >> file_loader.ctl

try:

bash code:
the_char=`echo ${LINE:4:1} | tr a-z A-Z`
echo " column3 CONSTANT '$the_char'," >> file_loader.tcl

Again, assuming you just want the O there and not the full name. If you want the full name, it'd be slightly more involved but not terribly so.

--
He who is not contented with what he has, would not be contented with what he would like to have. -Socrates


Maxo
Your tax dollars at work.
Premium,VIP
join:2002-11-04
Tallahassee, FL
clubs:
the_char=`echo ${LINE:4:1} | tr a-z A-Z`
The above line just returns the given string literal, not the results of the echo.
-
Forums » Tech and Talk » OS and Software » All Things UnixSendmail Config... »
« Grub Question.  


Sunday, 29-Nov 14:48:30 Terms of Use | Privacy Policy | Hosting by www.nac.net - DSL,Hosting & Co-lo | feedback | contact
over 10 years online! © 1999-2009 dslreports.com.
page compression OFF
Most commented news this week
· [124] Time Warner Cable Fires Broadside At Broadcasters
· [112] New AT&T Ad Campaign Hits Back At Verizon
· [96] Apple Joins AT&T Verizon Snark Fest
· [87] New Bill Takes Aim At Higher Verizon ETFs
· [80] TiVo Sees Record Customer Losses
· [77] Weekend Open Thread
· [76] Verizon CEO: Hulu Will Be Dead Soon
· [69] In-Flight Internet Headed For Bumpy Landing?
· [63] Thanksgiving Open Thread
· [40] EFF Wages War On Fine Print
Most people now reading
· Is Easynews down? [Filesharing Software]
· Are GPS's better today? [General Questions]
· Windows 7 boot manager editing questions [Microsoft Help]
· Grey Cup on the Web? [Canadian Chat]
· 3.x Feral Druid - Bear Tanking Guide [World of Warcraft]
· stopthetvtax [Canadian Chat]
· [NFL] Week 12 Games Thread [Sports Chat]
· [Newsgroups] Newzleech down? [Filesharing Software]
· Samsung LCD TV No Picture but has Sound [Electronics]
· [WIN7] Outlook express under Windows 7? [Microsoft Help]