Sorry, I wasn't specific enough. I'm looking to separate all the parenthesized words from the non-parenthesized:<br><br>input: <span style="color: rgb(255, 0, 0);">foo </span>(bar) <span style="color: rgb(255, 0, 0);">ice cream</span> (brown) <span style="color: rgb(255, 0, 0);">sky is blue</span> (airplane flies) <span style="color: rgb(255, 0, 0);">just flies</span><br>
<br>output:<br><span style="color: rgb(255, 0, 0);">foo ice cream sky is blue just flies</span><br>(bar) (brown) (airplane flies) --- with or without parenthesis, it doesn't matter.<br><br clear="all">-- Asher <br>
<br><br><div class="gmail_quote">On Wed, Feb 10, 2010 at 10:23 AM, Michael H. Warfield <span dir="ltr"><<a href="mailto:mhw@wittsend.com">mhw@wittsend.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Wed, 2010-02-10 at 09:53 -0500, Asher Vilensky wrote:<br>
> I need a script that would do this:<br>
<br>
> input file (text):<br>
> john (amy) fred (bob) julie (mike).....<br>
<br>
</div>Short on details here. Are you looking for the 1st, 3rd, and 5th white<br>
space separated fields? Do you want to quit after one line or stream<br>
the whole file?<br>
<div class="im"><br>
> output:<br>
> john fred julie<br>
<br>
> (amy) (bob) (mike) - optional, with or without parenthesis.<br>
<br>
> Perl or bash would do.<br>
<br>
</div>sed:<br>
<br>
sed -e 's/^\([^\s]*\)\s*[^\s]*\s*\([^\s]*\)\s*[^\s]*\s*\([^\s]*\)\s*[^\s]*/\1 \2 \3/'<br>
<br>
awk would do as well a sed here.<br>
<br>
bash:<br>
<br>
while read word1 word2 word3 word4 word5<br>
echo word1 word3 word5<br>
done<br>
<br>
Perl's pretty trivial too.<br>
<br>
Is that what you're after here or am I misunderstanding something there?<br>
Seems too simple.<br>
<br>
> Thanks.<br>
<br>
> -- Asher<br>
<br>
Mike<br>
<font color="#888888">--<br>
Michael H. Warfield (AI4NB) | (770) 985-6132 | mhw@WittsEnd.com<br>
/\/\|=mhw=|\/\/ | (678) 463-0932 | <a href="http://www.wittsend.com/mhw/" target="_blank">http://www.wittsend.com/mhw/</a><br>
NIC whois: MHW9 | An optimist believes we live in the best of all<br>
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!<br>
</font><br>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></blockquote></div><br>