Solved

Changing case of a variable

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

746 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