Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing case but only the first character

Status
Not open for further replies.

billbose

Programmer
Jan 15, 2001
66
US
hi,

How to change the first character of a record to upper case.

TIA.

Bill
 
Haven't time to figure this out at the moment, but the command

tr -s &quot;[:lower:]&quot; &quot;[:upper:]&quot; < input_file_name

will convert lower to upper for the specified input. I'm guessing you could use cut to isolate the 1st char from the rest, convert it, and then join the line back together again.

Greg.
 
You dit not say how many fields per line you have.
With this script is does not matter.


awk '{
for( ii = 1; ii <= NF; ii++)
printf( &quot;%s%s &quot;, toupper( substr( $ii, 1, 1)), substr( $ii, 2))
print &quot;&quot;
}' filetoconvert

succes Bill Gregor.Weertman@mailcity.com
 
Thank u greg and gregor.

BTW, The second awk script however works only with nawk in solaris 2.7. Thank you gregor for this script. It worked well.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top