![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
You probably want to use awk:
echo $bob | awk '{printf "%s%s", toupper(substr($1,1,1)), tolower(substr($1,2)) }' |
|
#3
|
|||
|
|||
|
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
|
|||
| Google The UNIX and Linux Forums |