The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Convert character in word to CAPS?? vadharah Shell Programming and Scripting 3 04-01-2008 08:44 AM
read a line from a csv file and convert a column to all caps orahi001 UNIX for Dummies Questions & Answers 3 12-31-2007 06:05 PM
Master Your Linux Keyboard (And Fix Caps Lock Forever) - EnterpriseNetworkingPlanet iBot UNIX and Linux RSS News 0 07-09-2007 09:30 PM
what is dead.letter ?? jambesh Shell Programming and Scripting 2 08-30-2006 04:25 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-23-2008
Krrishv Krrishv is offline
Registered User
  
 

Join Date: Dec 2006
Location: CA,United States
Posts: 186
changing first letter to CAPS

Hi,

I want to convert the first letter of this word from lowecase to uppercase.

Assume a letter united. I want to translate to United

Please let me know a simple way to do that.

Thanks.
  #2 (permalink)  
Old 04-23-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 753

Code:
echo united | awk '{print toupper(substr($0,1,1))""substr($0,2)}'

  #3 (permalink)  
Old 04-23-2008
Krrishv Krrishv is offline
Registered User
  
 

Join Date: Dec 2006
Location: CA,United States
Posts: 186
Hi Shamrock,

Thanks for the reply. But this is not working.

agamemnon:/home/x033870>echo `hostname` | awk '{print toupper(substr($0,1,1))""substr($0,2)}'
agamemnon
  #4 (permalink)  
Old 04-23-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,440

Code:
echo `hostname` | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}'

  #5 (permalink)  
Old 04-23-2008
Krrishv Krrishv is offline
Registered User
  
 

Join Date: Dec 2006
Location: CA,United States
Posts: 186
In HP UX it is converting everything

genova$ /Application/psoftlnk/hr83:echo `hostname` | awk 'BEGIN{OFS=FS=""}{$1=to
upper($1);print}'
GENOVA

In SUn OS nothing changed..its all lowercase...

i want only the first letter
  #6 (permalink)  
Old 04-24-2008
SandmanCL SandmanCL is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 9
using perl

Sort of cheating since it requires perl installed:

$ echo united | perl -pe 's/^(\w)/\u$1/'
United
  #7 (permalink)  
Old 04-24-2008
uvrakesh uvrakesh is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 78
Personally i feel that sed should be given a chance then we should think about awk and perl(perl commands are more or less same like sed)

echo united | sed 's/^./\U/g'


i hope this would work

Best Regards,
Rakesh Uv
Closed Thread

Bookmarks

Tags
hp-ux, linux, proper case, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0