Solved

Changing case of a variable

Posted on 2004-08-26
2
254 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
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now