[ale] here's one for the script wizards

Asher Vilensky ashervilensky at gmail.com
Wed Feb 10 10:45:38 EST 2010


Sorry, I wasn't specific enough.  I'm looking to separate all the
parenthesized words from the non-parenthesized:

input: foo (bar) ice cream (brown) sky is blue (airplane flies) just flies

output:
foo ice cream sky is blue just flies
(bar) (brown) (airplane flies)     --- with or without parenthesis, it
doesn't matter.

-- Asher


On Wed, Feb 10, 2010 at 10:23 AM, Michael H. Warfield <mhw at wittsend.com>wrote:

> On Wed, 2010-02-10 at 09:53 -0500, Asher Vilensky wrote:
> > I need a script that would do this:
>
> > input file (text):
> > john (amy) fred (bob) julie (mike).....
>
> Short on details here.  Are you looking for the 1st, 3rd, and 5th white
> space separated fields?  Do you want to quit after one line or stream
> the whole file?
>
> > output:
> > john fred julie
>
> > (amy) (bob) (mike)        -  optional, with or without parenthesis.
>
> > Perl or bash would do.
>
> sed:
>
> sed -e
> 's/^\([^\s]*\)\s*[^\s]*\s*\([^\s]*\)\s*[^\s]*\s*\([^\s]*\)\s*[^\s]*/\1 \2
> \3/'
>
> awk would do as well a sed here.
>
> bash:
>
> while read word1 word2 word3 word4 word5
>        echo word1 word3 word5
> done
>
> Perl's pretty trivial too.
>
> Is that what you're after here or am I misunderstanding something there?
> Seems too simple.
>
> > Thanks.
>
> > -- Asher
>
> Mike
> --
> Michael H. Warfield (AI4NB) | (770) 985-6132 |  mhw at WittsEnd.com
>   /\/\|=mhw=|\/\/          | (678) 463-0932 |
> http://www.wittsend.com/mhw/
>   NIC whois: MHW9          | An optimist believes we live in the best of
> all
>  PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20100210/c43a8f9f/attachment-0001.html 


More information about the Ale mailing list