The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 04:59 AM
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 10:10 AM
ls command problem buckhtr77 SUN Solaris 2 12-06-2005 04:16 PM
Problem while using Sed command gopskrish UNIX for Dummies Questions & Answers 2 06-27-2005 11:26 AM
Sed command problem tomapam Shell Programming and Scripting 1 12-20-2002 08:02 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-02-2007
ravi raj kumar ravi raj kumar is offline
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
  #2 (permalink)  
Old 07-02-2007
zzxtty zzxtty is offline
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)) }'
  #3 (permalink)  
Old 07-02-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
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
Sponsored Links
Closed Thread

Bookmarks

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 07:13 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