Skip to contentSkip to conversation

Capitalize a variable in a shell script

DISCUSSION Diego Alencar Alves de Lima 2 participants 2 messages Oct 30, 2006 – Oct 31, 2006

lore
Share & tools
lore
#0 lore raw

How can I capitalize an existing variable in a shell script? Currently $variable is www.domain.com, and I need to create a $variable1 that contains WWW.DOMAIN.COM (I am currently using bash as shell)

Thanks a lot

Signature · 2 lines
Diego Lima
http://sg.homelinux.com:81
#1 lore raw

Hello,

Try this...

variable2=echo $variable1 | tr [a-z] [A-Z]

Cheers,
Frank

Quoted 4 lines · Diego Alencar Alves de Lima

How can I capitalize an existing variable in a shell script? Currently $variable is www.domain.com, and I need to create a $variable1 that contains WWW.DOMAIN.COM (I am currently using bash as shell)

Thanks a lot

Signature · 1 line
Best if consumed promptly upon delivery or take out... :)

begin:vcard
fn:Franklin Chua
n:Chua;Franklin
org:NEC Telecom Software Philippines, Inc.
adr:;;2nd Flr. Bonifacio Technology Center;Taguig, Metro Manila;;;Philippines email;internet:[email protected]
title:Software Design Engineer II
tel;work:+632 818-0913
tel;fax:+632 818-0927
note;quoted-printable:NECNET: 800 63 (91) 5411=0D=0A=

	NECFAX: 800 63 (91) 5209

x-mozilla-html:TRUE
version:2.1
end:vcard