[comp.unix.questions] Convert 'a' to 'A' in a Shell-Script

koe@kivax.UUCP (Diana Koehler) (01/30/91)

How can I convert "lowercase" characters in "uppercase" characters
in a Shell-Script.
f.e. convert all 'a' to 'A' ?
(awk, sed ??)

Thanks in advance

Diana

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

Diana Koehler                     Tel.:   +49 7721 867034
Kienzle Computersysteme
Abt. 011.2                        e-mail: koe@kivax.UUCP
Postfach 1640                             ..!mcsun!unido!kivax!koe
D-7730 VS-Villingen                       ..!uunet!unido!kivax!koe

ewoods@hemel.bull.co.uk (Eoin Woods) (01/31/91)

koe@kivax.UUCP (Diana Koehler) writes:

>How can I convert "lowercase" characters in "uppercase" characters
>in a Shell-Script.
>f.e. convert all 'a' to 'A' ?
>(awk, sed ??)

Try tr(1), for example :

abc='Hello'
def=`echo $abc | tr [a-z][A-Z]`
echo $def

Will produce :

HELLO

Eoin.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~    Eoin Woods, Software Development Group, Bull HN Information Systems,   ~
~                Maxted Road, Hemel Hempstead, Herts HP2 7DZ, UK.           ~
~                Tel : +44 442 232222 x4823   Fax : +44 442 234084          ~
~      < Eoin.Woods@hemel.bull.co.uk  or   ...!uunet!ukc!brno!ewoods>       ~
~          < When do we start news group comp.os.emacs ?  :-) >             ~

ricks@ncrcae.Columbia.NCR.COM (Rick Silverstein) (01/31/91)

In article <888@kivax.UUCP> koe@kivax.UUCP (Diana Koehler) writes:
>
>
>How can I convert "lowercase" characters in "uppercase" characters
>in a Shell-Script.
>f.e. convert all 'a' to 'A' ?
>(awk, sed ??)
>

/usr/bin/tr works well for me.  Use the syntax:  tr "[a-z]" "[A-Z]"
This reads from stdin and writes to stdout, mapping a to A, b to B, ...
and z to Z so 'echo hello | tr "[a-z]" "[A-Z]"' outputs HELLO.

sun@me.utoronto.ca (Andy Sun Anu-guest) (02/03/91)

koe@kivax.UUCP (Diana Koehler) writes:



>How can I convert "lowercase" characters in "uppercase" characters
>in a Shell-Script.
>f.e. convert all 'a' to 'A' ?
>(awk, sed ??)

>Thanks in advance

>Diana

>------------------------------------------------------------------------

>Diana Koehler                     Tel.:   +49 7721 867034
>Kienzle Computersysteme
>Abt. 011.2                        e-mail: koe@kivax.UUCP
>Postfach 1640                             ..!mcsun!unido!kivax!koe
>D-7730 VS-Villingen                       ..!uunet!unido!kivax!koe

I know you'll probably get lots of replies from people because the
above is a trivial one. There is a command called "tr" (for translate,
I think it is a SysV command) that does translations. Typing

		tr A-Z a-z filename

will convert all upper cases to lower cases in file filename.

Andy

sleepy@wybbs.mi.org (Mike Faber) (02/04/91)

>>How can I convert "lowercase" characters in "uppercase" characters
>>in a Shell-Script.
>>f.e. convert all 'a' to 'A' ?
>/usr/bin/tr works well for me.  Use the syntax:  tr "[a-z]" "[A-Z]"

Good item for FAQ.