home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.shell:4554 comp.lang.misc:3509
- Newsgroups: comp.unix.shell,comp.lang.misc
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!elroy.jpl.nasa.gov!sdd.hp.com!sgiblab!munnari.oz.au!cs.mu.OZ.AU!minh
- From: minh@lis.rch.unimelb.edu.au (Minh Tran)
- Subject: Re: Need script (awk/sed/...) to remove dashes and do initial caps
- Message-ID: <9231112.13182@mulga.cs.mu.OZ.AU>
- Sender: news@cs.mu.OZ.AU
- Organization: Computer Science, University of Melbourne, Australia
- X-Newsreader: TIN [version 1.1 PL6]
- References: <Bx5t40.5DB@unx.sas.com>
- Date: Fri, 6 Nov 1992 01:17:31 GMT
- Lines: 46
-
- Mark Burhans (sasmob@chewy.unx.sas.com) wrote:
- >
- > Here is an awk script that seems to work for me:
- >
- > ----Cut Here----
- > {
- > for( f=1; f<=NF; f++ )
- > {
- > # 1. Make first character Upper Case.
- > # 2. Make rest of the word Lower Case.
- >
- > sub( substr($f,1,1), toupper( substr( $f, 1, 1)), $f );
- > sub( substr($f,2), tolower( substr($f,2)), $f );
- >
- > # If a '-' is found, get rid of it and make the next
- > # character Upper Case.
- >
- > while( (i=index( $f, "-" )) != 0 )
- > {
- > pattern = substr( $f, i, 2 );
- > sub( pattern, toupper(substr($f,i+1,1)), $f);
- > }
- >
- > # Output what you have.
- >
- > print $f
- > }
- > }
- > ----Cut Here----
- >
-
- This should work as well ...
-
- {
- split($1, parts, "-") ;
- printf("%s%s", toupper(substr(parts[1],1,1)), tolower(substr(parts[1],2)));
- printf("%s%s\n", toupper(substr(parts[2],1,1)), tolower(substr(parts[2],2))) }
-
- ---
- minh
-
- --
- |> B\iochemistry Minh Tra/N <|
- |> I\nformation minh@lis.rch.unimelb.edu.a/U <|
- |> S\ervice (03) 345-590/8 <|
- |> D\epartment Melbourne, Australi/A <|
-