• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

Changing case of a variable


How can I change case of first letter of a variable in shell programming?

#!/bin/sh

$name = "hello"
$name = toTitleCase($name);
echo $name

Is there anything like titleCase or soemthing that will change case of first letter to upper case.

Thanks in advance.


0
kiranchandbv
Asked:
kiranchandbv
1 Solution
 
MysidiaCommented:
$capitalized = `echo $name |awk '{print toupper(substr($0,0,1)) substr($0,2)}'`
0
 
kiranchandbvAuthor Commented:
Thanks Mysidia,

I could make it work with small change in the index value in substr.

Thanks again.

name="hello"
echo $name
name=`echo $name |awk '{print toupper(substr($0,1,1))substr($0,2)}'`
echo $name
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now