Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 86628 invoked from network); 14 Dec 2004 20:35:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 14 Dec 2004 20:35:44 -0000 Received: (qmail 34775 invoked by uid 500); 14 Dec 2004 19:27:33 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 34721 invoked by uid 500); 14 Dec 2004 19:27:33 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 34666 invoked by uid 99); 14 Dec 2004 19:27:32 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from mail14.ca.com (HELO mail14.ca.com) (208.232.182.10) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 14 Dec 2004 11:27:27 -0800 Received: from usilms22.ca.com ([141.202.201.22]) by mail14.ca.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 14 Dec 2004 13:27:21 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: yet another regex question Date: Tue, 14 Dec 2004 14:27:20 -0500 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: yet another regex question Thread-Index: AcTiB1/mKUytjKqzTNKFgt1R3aoTwgAAfpnAAAJb1zA= From: "Nemana, Satya V" To: "Ant Users List" X-OriginalArrivalTime: 14 Dec 2004 19:27:21.0288 (UTC) FILETIME=[EE8F6480:01C4E212] X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Gilbert, consider using cygwin on windows. Here are the awk and perl scipts called by bash to do this. I try it in Ant, but I am not yet so good at it. Program: splitter.sh #!/bin/bash awk ' BEGIN { flag=3D0; knt=3D0; } /^bin/ { flag =3D 1; next; } /^mail/ { flag =3D 2; next; } flag =3D=3D 1 { knt +=3D 1; print knt, $0 ;} END { print "Awk found " knt " lines"; } ' < /etc/passwd perl -e ' $knt=3D0; while ( $line =3D <> ) { if ( $line =3D~ m/^bin/ ) { $flag=3D1; next; }; if ( $line =3D~ m/^mail/ ) { $flag=3D0; }; if ( $flag ) { $knt +=3D 1; print "$knt $line"; }; }; print "Perl found $knt lines"; ' < /etc/passwd Results: #./splitter.sh 1 daemon:x:2:2:Daemon:/sbin:/bin/bash 2 lp:x:4:7:Printing daemon:/var/spool/lpd:/bin/bash Awk found 2 lines 1 daemon:x:2:2:Daemon:/sbin:/bin/bash 2 lp:x:4:7:Printing daemon:/var/spool/lpd:/bin/bash Perl found 2 lines -Satya -----Original Message----- From: RADEMAKERS Tanguy [mailto:Tanguy.RADEMAKERS@swift.com]=20 Sent: Tuesday, December 14, 2004 1:20 PM To: Ant Users List Subject: RE: yet another regex question The power of awk and many other goodies: http://GnuWin32.sourceforge.net/ /t=20 >-----Original Message----- >From: Gilbert Rebhan [mailto:ant@schillbaer.de]=20 >Sent: Tuesday, December 14, 2004 6:30 PM >To: Ant Users List >Subject: Re: yet another regex question > >Hi, > >Nemana, Satya V wrote: >> Gilbert, I wrote an awk script to do this in the past. I=20 >need to search >> for it now. Clue is to add 3 lines in the body of the awk.=20 >(line-1) use >> if statement and set a flag to 1 and "skip 1", if pattern1=20 >matches with >> $0 and then (line-2) reset the flag to 0 and "skip 1", if=20 >the pattern2 >> matches with $0. And at the end (line-3) print $0, if the=20 >flag is tested >> with 1. Here flag is an awk variable. Let me know if you=20 >still need it >> and I can get it. > >thanks for your friendly offer, but ... >My env here : > >_Windows2000_ / Ant 1.6.2 / j2sdk 1.4.2_06 > >(optional for regex i have jakarta-oro) > >so i'm not able to use the power of awk ... > >bye4now, Gilbert > >--------------------------------------------------------------------- >To unsubscribe, e-mail: user-unsubscribe@ant.apache.org >For additional commands, e-mail: user-help@ant.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org