Solved

Changing case of a variable

Posted on 2004-08-26
2
282 Views
Last Modified: 2010-04-20

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
Comment
Question by:kiranchandbv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Mysidia earned 50 total points
ID: 11919307
$capitalized = `echo $name |awk '{print toupper(substr($0,0,1)) substr($0,2)}'`
0
 

Author Comment

by:kiranchandbv
ID: 11926421
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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question