Unix Shell - Re: convert 1st char of a word to uppercase

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > April 2005 > Re: convert 1st char of a word to uppercase





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: convert 1st char of a word to uppercase
Michael Heiming

2005-04-26, 2:49 am

In comp.unix.shell Ed Morton <morton@lsupcaemnt.com>:


> Michael Heiming wrote:


> <snip>
[vbcol=seagreen]
> I'd just loop through the fields:


> awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1'


> It changes white-space but there's ways round that if it's a problem....


Yep, this should work, but the line is getting longer and longer
in addition to just another formating problem. Looks like using
vim ':%s/\<\(.\)\([^ ]*\)/\u\1\L\2/g' would be the shortest
possible way so far.;)

--
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)
mail: echo zvpunry@urvzvat.qr | PERL -pe 'y/a-z/n-za-m/'
#bofh excuse 438: sticky bit has come loose
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com