home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.shell:4609 comp.lang.misc:3557
- Newsgroups: comp.unix.shell,comp.lang.misc
- Path: sparky!uunet!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: <9231509.5038@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: <BxB2D1.7yL@unx.sas.com>
- Date: Mon, 9 Nov 1992 22:32:39 GMT
- Lines: 41
-
- Mark Burhans (sasmob@chewy.unx.sas.com) wrote:
- > |> {
- > |> 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))) }
- >
- > It works if there is only one word with one "-" in it. This is neat though.
- > That could probably be modified with some effort to handle more than one
- > word per line, and more than one "-". Some of the LISP I've written and
- > seen has variables and procedures with names like:
- > "print-no-of-arguments" or
- > "get-next-field"
- >
- > I messed with this awk for a minute (didn't put much into it) and didn't get
- > very far.
- >
- > Nice input.
- >
-
- Having got this far the rest is quite easy:
-
- {
- for (i = 1; i <= NF; i++)
- {
- n = split($i, part, "-") ;
- for (j = 1; j <= n; j++)
- printf("%s%s", toupper(substr(part[j], 1, 1)), tolower(substr(part[j], 2)));
- printf(" "); # Just for this example
- }
- printf("\n");
- }
-
- Anyway you got the idea.
- ---
- 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 <|
-