Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting lowercase into Initcap on Unix 1

Status
Not open for further replies.

skuthe

Programmer
Sep 10, 2002
33
0
0
US
Hi,
Can anyone help me to convert a parameter, supplied to a unix script, from lowercase to Initcap.
I tried using tr but could not get this done in a single command.

f.eg:
====
My shell script is test.com, I run this script with a parameter ...

$test.com diamond

The result I expect is Diamond

Pl. help.
Thanks.
 
var=`echo $1 | awk '{print toupper(substr($1,1,1)) tolower(substr($1,2))}'`

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV, it worked great !.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top