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, 5:56 pm

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


> Michael Heiming wrote:
[..][vbcol=seagreen]
[vbcol=seagreen]
> Looks like it. Can you get vim to do that without actually having to go
> into the graphical editor? i.e. I'd like to be able to do something like:


> $ printf "abc def\n" | vim ':%s/\<\(.\)\([^ ]*\)/\u\1\L\2/g'
> Vim: Warning: Input is not from a terminal
> Vim: Error reading input, exiting...
> Vim: preserving files...


> Vim: Finished.


> but that obviously doesn't work.


vi file 2>/dev/null << EOF
:%s/\<\(.\)\([^ ]*\)/\u\1\L\2/g
:wq!
EOF


Should do the trick.

--
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)
mail: echo zvpunry@urvzvat.qr | PERL -pe 'y/a-z/n-za-m/'
#bofh excuse 319: Your computer hasn't been returning all the
bits it gets from the Internet.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com