Re: sed/awk, instead of Perl

2008-08-26 Thread Oliver Fromme
Walt Pawley wrote: > wump$ time sed "s/ .*//" Desktop/klog > kadr1 Note that this is a job for cut(1): $ cut -d" " -f1 input Interestingly, the fastest way to do that job is to use a regular expression with Python. This is about twice as fast as the proposed perl solution: $ python -c 'import

Re: sed/awk, instead of Perl

2008-08-24 Thread Wayne Sierke
On Sat, 2008-08-23 at 15:16 -0700, Walt Pawley wrote: > At 10:01 AM +0100 8/23/08, Matthew Seaman wrote: > >Walt Pawley wrote: > >> > >> At the risk of beating this to death, I just happened to > >> stumble on a real world example of why one might want to use > >> Perl for sed-ly stuff. > >> ... s

Re: sed/awk, instead of Perl

2008-08-23 Thread Walt Pawley
At 10:01 AM +0100 8/23/08, Matthew Seaman wrote: >Walt Pawley wrote: >> >> At the risk of beating this to death, I just happened to >> stumble on a real world example of why one might want to use >> Perl for sed-ly stuff. >> ... snip ... >> wump$ ls -l Desktop/klog >> -rw-r--r-- 1 wump 1001 527

Re: sed/awk, instead of Perl

2008-08-23 Thread Matthew Seaman
Walt Pawley wrote: At 9:59 AM +0200 8/22/08, Oliver Fromme wrote: - The perl command you wrote above is pretty much a sed command anyway (except you incorrectly used non-portable regular expression syntax). Why use perl to execute a sed command? At the risk of beating this to death, I

Re: sed/awk, instead of Perl

2008-08-22 Thread Peter Boosten
Walt Pawley wrote: > At 9:59 AM +0200 8/22/08, Oliver Fromme wrote: > > wump$ ls -l Desktop/klog > -rw-r--r-- 1 wump 1001 52753322 22 Aug 16:37 Desktop/klog > wump$ time sed "s/ .*//" Desktop/klog > kadr1 > > real0m10.800s > user0m10.580s > sys 0m0.250s > wump$ time perl -pe 's/ .

Re: sed/awk, instead of Perl

2008-08-22 Thread Walt Pawley
At 9:59 AM +0200 8/22/08, Oliver Fromme wrote: > - The perl command you wrote above is pretty much a sed > command anyway (except you incorrectly used non-portable > regular expression syntax). Why use perl to execute a > sed command? At the risk of beating this to death, I just happened t

Re: sed/awk, instead of Perl

2008-08-22 Thread Steve Bertrand
Oliver Fromme wrote: Walt Pawley wrote: > I guess getting old, nearly blind and mind numbing close to > brain dead is better than the alternative. Try this (sooner or > later I've got to get it right)... > > perl -pe 's/(.*?)\.(.*)\t.*/[EMAIL PROTECTED]/' input_file > output_file >

Re: sed/awk, instead of Perl

2008-08-22 Thread Oliver Fromme
Walt Pawley wrote: > Walt Pawley wrote: > > Walt Pawley wrote: > > > Steve Bertrand wrote: > > > > - read email addresses from a file in the format: > > > > > > > > user.name TAB domain.tld > > > > > > > > - convert it to: > > > > > > > > [EMAIL PROTECTED] > > > > > > > > - write it

Re: sed/awk, instead of Perl

2008-08-21 Thread Walt Pawley
At 4:19 PM -0700 8/21/08, Walt Pawley wrote: >At 3:49 PM -0700 8/21/08, Walt Pawley wrote: > >>At 8:46 AM -0400 8/21/08, Steve Bertrand wrote: >> >>>- read email addresses from a file in the format: >>> >>>user.name TAB domain.tld >>> >>>- convert it to: >>> >>>[EMAIL PROTECTED] >>> >>>- write it

Re: sed/awk, instead of Perl

2008-08-21 Thread Walt Pawley
At 3:49 PM -0700 8/21/08, Walt Pawley wrote: >At 8:46 AM -0400 8/21/08, Steve Bertrand wrote: > >>- read email addresses from a file in the format: >> >>user.name TAB domain.tld >> >>- convert it to: >> >>[EMAIL PROTECTED] >> >>- write it back to either a new file, the original file, or to STDOUT

Re: sed/awk, instead of Perl

2008-08-21 Thread Walt Pawley
At 8:46 AM -0400 8/21/08, Steve Bertrand wrote: >- read email addresses from a file in the format: > >user.name TAB domain.tld > >- convert it to: > >[EMAIL PROTECTED] > >- write it back to either a new file, the original file, or to STDOUT I'm curious why Perl isn't a decent choice. I think I'd

OT: Re: sed/awk, instead of Perl

2008-08-21 Thread Gerard
On Thu, 21 Aug 2008 15:49:17 +0200 (CEST) Oliver Fromme <[EMAIL PROTECTED]> wrote: > > To put it plainly, can anyone, if it's possible, provide a single > > line sed/awk pipeline that can: > > > > - read email addresses from a file in the format: > > > > user.name TAB domain.tld > > > > - conve

Re: sed/awk, instead of Perl

2008-08-21 Thread Oliver Fromme
Steve Bertrand wrote: > To put it plainly, can anyone, if it's possible, provide a single line > sed/awk pipeline that can: > > - read email addresses from a file in the format: > > user.name TAB domain.tld > > - convert it to: > > [EMAIL PROTECTED] With awk(1): awk '{sub(/\./,

Re: sed/awk, instead of Perl

2008-08-21 Thread Wayne Sierke
On Thu, 2008-08-21 at 15:12 +0200, Wojciech Puchar wrote: > > > > cat tcpdump.txt | awk '{if ($3 != "192.168.100.204.25") print $3}' | \ > > awk '{FS = "."} {print $1,".",$2,".",$3,"."$4}' | sed s/" "//g > > > why you all abuse "cat" command. simply awk http://lists.freebsd.org/mailman/listi

Re: sed/awk, instead of Perl

2008-08-21 Thread Nikos Vassiliadis
On Thursday 21 August 2008 16:19:08 Wojciech Puchar wrote: > > If you have nothing nice to say, or can't contribute or point out more > > this is a contribution. unless you can't see it. There are assumptions that combining more than three cats (*) in a pipeline, the universe will explode! (*) Th

Re: sed/awk, instead of Perl

2008-08-21 Thread Steve Bertrand
Anton Shterenlikht wrote: On Thu, Aug 21, 2008 at 09:17:43AM -0400, Steve Bertrand wrote: Wojciech Puchar wrote: Try the following: cat t.txt | awk -F\t '{split($1, arr, "."); printf("[EMAIL PROTECTED]", arr[ 1], arr[2], $2);}' a shorter way: sed s/\\./_/g | awk '{print $1 "@example.com"}

Re: sed/awk, instead of Perl

2008-08-21 Thread Anton Shterenlikht
On Thu, Aug 21, 2008 at 09:17:43AM -0400, Steve Bertrand wrote: > Wojciech Puchar wrote: > >> > >> Try the following: > >> > >> > >> cat t.txt | awk -F\t '{split($1, arr, "."); printf("[EMAIL PROTECTED]", > >> arr[ > >> 1], arr[2], $2);}' a shorter way: sed s/\\./_/g | awk '{print $1 "@example.

Re: sed/awk, instead of Perl

2008-08-21 Thread Steve Bertrand
Wojciech Puchar wrote: ...but that is just semantics, relative to the intent and purpose of this no. using cat make one more pipe, one more process and is noticably slower Yes it's agreed... I was joking around with Matthias for kind-heartedly pointing out the err of our ways. Steve

Re: sed/awk, instead of Perl

2008-08-21 Thread Wojciech Puchar
If you have nothing nice to say, or can't contribute or point out more this is a contribution. unless you can't see it. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any

Re: sed/awk, instead of Perl

2008-08-21 Thread Steve Bertrand
Wojciech Puchar wrote: Try the following: cat t.txt | awk -F\t '{split($1, arr, "."); printf("[EMAIL PROTECTED]", arr[ 1], arr[2], $2);}' and third If you have nothing nice to say, or can't contribute or point out more efficient ways of doing things in a polite manner, then 'don't say not

Re: sed/awk, instead of Perl

2008-08-21 Thread Wojciech Puchar
...but that is just semantics, relative to the intent and purpose of this no. using cat make one more pipe, one more process and is noticably slower ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-quest

Re: sed/awk, instead of Perl

2008-08-21 Thread Wojciech Puchar
Try the following: cat t.txt | awk -F\t '{split($1, arr, "."); printf("[EMAIL PROTECTED]", arr[ 1], arr[2], $2);}' and third ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, s

Re: sed/awk, instead of Perl

2008-08-21 Thread Wojciech Puchar
Regards, cat file.txt | ( while read user domain; do echo "[EMAIL PROTECTED]"; done ) second cat abuser while read user domain; do echo "[EMAIL PROTECTED]"; done http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Re: sed/awk, instead of Perl

2008-08-21 Thread Wojciech Puchar
cat tcpdump.txt | awk '{if ($3 != "192.168.100.204.25") print $3}' | \ awk '{FS = "."} {print $1,".",$2,".",$3,"."$4}' | sed s/" "//g why you all abuse "cat" command. simply awk Steve ___ freebsd-questions@freebsd.org mailing list http://lists

Re: sed/awk, instead of Perl

2008-08-21 Thread Steve Bertrand
Matthias Apitz wrote: El día Thursday, August 21, 2008 a las 05:54:29AM -0700, Joseph Olatt escribió: Try the following: cat t.txt | awk -F\t '{split($1, arr, "."); printf("[EMAIL PROTECTED]", arr[ 1], arr[2], $2);}' where t.txt: john.doeexample.com Despite of the magic awk(1) or whil

Re: sed/awk, instead of Perl

2008-08-21 Thread Matthias Apitz
El día Thursday, August 21, 2008 a las 05:54:29AM -0700, Joseph Olatt escribió: > Try the following: > > > cat t.txt | awk -F\t '{split($1, arr, "."); printf("[EMAIL PROTECTED]", arr[ > 1], arr[2], $2);}' > > where t.txt: > john.doeexample.com Despite of the magic awk(1) or while-loops: t

Re: sed/awk, instead of Perl

2008-08-21 Thread Steve Bertrand
Joseph Olatt wrote: Try the following: cat t.txt | awk -F\t '{split($1, arr, "."); printf("[EMAIL PROTECTED]", arr[ 1], arr[2], $2);}' where t.txt: john.doeexample.com This did the job, the only modification I needed to make was manually replace $2 with the string of the domain I need

Re: sed/awk, instead of Perl

2008-08-21 Thread Steve Bertrand
Barry Byrne wrote: Quoting "Steve Bertrand" <[EMAIL PROTECTED]>: few passes over a few files. To put it plainly, can anyone, if it's possible, provide a single line sed/awk pipeline that can: - read email addresses from a file in the format: user.name TAB domain.tld - convert it to: [EM

Re: sed/awk, instead of Perl

2008-08-21 Thread Joseph Olatt
On Thu, Aug 21, 2008 at 08:46:47AM -0400, Steve Bertrand wrote: > I'm frequently having to modify/convert email addresses from one > format/domain to another. > > Usually, I slap together a quick Perl script to do this for me. I don't > do it frequently enough to keep track which one of my scrip

Re: sed/awk, instead of Perl

2008-08-21 Thread Barry Byrne
Quoting "Steve Bertrand" <[EMAIL PROTECTED]>: few passes over a few files. To put it plainly, can anyone, if it's possible, provide a single line sed/awk pipeline that can: - read email addresses from a file in the format: user.name TAB domain.tld - convert it to: [EMAIL PROTECTED] - w

Re: sed/awk, instead of Perl

2008-08-21 Thread Steve Bertrand
Steve Bertrand wrote: To put it plainly, can anyone, if it's possible, provide a single line sed/awk pipeline that can: To answer my own post, I found in some past notes something I drummed up quite a while ago that I can most certainly modify to suit my needs: # Cat the tcpdump output file