[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] here's one for the script wizards
- Subject: [ale] here's one for the script wizards
- From: mhw at WittsEnd.com (Michael H. Warfield)
- Date: Wed, 10 Feb 2010 10:23:52 -0500
- In-reply-to: <[email protected]>
- References: <[email protected]>
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!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
Url : http://mail.ale.org/pipermail/ale/attachments/20100210/b18167ec/attachment.bin