Unix Technical Forum

find & replace help

This is a discussion on find & replace help within the Sco Unix forums, part of the Unix Operating Systems category; --> I want to convert to upper case the first letter of all the words in a text document, how ...


Go Back   Unix Technical Forum > Unix Operating Systems > Sco Unix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-15-2008, 05:41 PM
Enrique A
 
Posts: n/a
Default find & replace help

I want to convert to upper case the first letter of all the words in a text
document, how can I do that with vi ?

do I do something like this :

:1,$s/ ^[a-z]/ ^[A-Z]/g
^ ^
blank blank
space space


Thanks


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-15-2008, 05:41 PM
Jean-Pierre Radley
 
Posts: n/a
Default Re: find & replace help

Enrique A typed (on Fri, Jan 13, 2006 at 07:06:51PM +0000):
| I want to convert to upper case the first letter of all the words in a text
| document, how can I do that with vi ?
|
| do I do something like this :
|
| :1,$s/ ^[a-z]/ ^[A-Z]/g
| ^ ^
| blank blank
| space space

You think coding filePro's uplow edit is child's play? Think again! :-)

--
JP
==> http://www.frappr.com/cusm <==
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-15-2008, 05:41 PM
Roger Cornelius
 
Posts: n/a
Default Re: find & replace help

Enrique A wrote:
> I want to convert to upper case the first letter of all the words in a text
> document, how can I do that with vi ?
>
> do I do something like this :
>
> :1,$s/ ^[a-z]/ ^[A-Z]/g
> ^ ^
> blank blank
> space space


If you're willing to use vim rather than vi, see if this thread helps:

http://groups.google.com/group/comp....3ec94bc16cc9e9

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-15-2008, 05:41 PM
Steve M. Fabac, Jr.
 
Posts: n/a
Default Re: find & replace help

Enrique A wrote:
>
> I want to convert to upper case the first letter of all the words in a text
> document, how can I do that with vi ?
>
> do I do something like this :
>
> :1,$s/ ^[a-z]/ ^[A-Z]/g
> ^ ^
> blank blank
> space space
>
> Thanks


I have found this to work:

1,$s/.*/\L&/ <- Make everything lower case
g/[a-z][a-z]*/s//\u&/g <- Make every first letter in string of letters upper case.
g/"[A-Z][a-z]"/s//\U&/g <- Correct two letter state abbreviations to all uppercase ("," delimited file)

--

Steve Fabac
S.M. Fabac & Associates
816/765-1670
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-15-2008, 05:42 PM
Enrique A
 
Posts: n/a
Default Re: find & replace help


"Steve M. Fabac, Jr." <smfabac@att.net> wrote in message
news:43C9306E.E6FDD4C2@att.net...
> Enrique A wrote:
>>
>> I want to convert to upper case the first letter of all the words in a
>> text
>> document, how can I do that with vi ?
>>
>> do I do something like this :
>>
>> :1,$s/ ^[a-z]/ ^[A-Z]/g
>> ^ ^
>> blank blank
>> space space
>>
>> Thanks

>
> I have found this to work:
>
> 1,$s/.*/\L&/ <- Make everything lower case
> g/[a-z][a-z]*/s//\u&/g <- Make every first letter in string of letters
> upper case.
> g/"[A-Z][a-z]"/s//\U&/g <- Correct two letter state abbreviations to
> all uppercase ("," delimited file)
>
> --
>
> Steve Fabac
> S.M. Fabac & Associates
> 816/765-1670
>


Awesome! It works great!. Thanks so much!


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:25 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com