The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem in awk command viveksnv Shell Programming and Scripting 3 03-03-2008 01:59 AM
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 07:10 AM
ls command problem buckhtr77 SUN Solaris 2 12-06-2005 01:16 PM
Problem while using Sed command gopskrish UNIX for Dummies Questions & Answers 2 06-27-2005 08:26 AM
Sed command problem tomapam Shell Programming and Scripting 1 12-20-2002 05:02 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-02-2007
Registered User
 

Join Date: Dec 2006
Location: hyderabad
Posts: 102
problem with tr command

Hi,
Pls consider the following function and function Call

normalize()
{
# Return string with first char uppercase, next two lowercase
echo -n $1 | cut -c1 | tr '[[:lower:]]' '[[:upper:]]'
echo $1 | cut -c2-3| tr '[[:upper:]]' '[[:lower:]]'
}

day="$(normalize mon)"


when i print the value of "day" ,It is printing like "M on" which should be "Mon".
I want to remove the additional space at the time of translation.

Any help pls.
cheers
RK
Reply With Quote
Forum Sponsor
  #2  
Old 07-02-2007
Registered User
 

Join Date: Jul 2007
Posts: 1
You probably want to use awk:

echo $bob | awk '{printf "%s%s", toupper(substr($1,1,1)), tolower(substr($1,2)) }'
Reply With Quote
  #3  
Old 07-02-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
day=""
normalize()
{
# Return string with first char uppercase, next two lowercase
day=$(echo $1 | cut -c1 | tr '[[:lower:]]' '[[:upper:]]')
day=${day}$(echo $1 | cut -c2-3| tr '[[:upper:]]' '[[:lower:]]')
}
normalize mon
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0