From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4907 invoked from network); 8 Jul 2005 17:16:49 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 8 Jul 2005 17:16:49 -0000 Received: (qmail 93941 invoked from network); 8 Jul 2005 17:16:42 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 8 Jul 2005 17:16:42 -0000 Received: (qmail 16568 invoked by alias); 8 Jul 2005 17:16:36 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9061 Received: (qmail 16558 invoked from network); 8 Jul 2005 17:16:35 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 8 Jul 2005 17:16:35 -0000 Received: (qmail 92919 invoked from network); 8 Jul 2005 17:16:35 -0000 Received: from vms046pub.verizon.net (206.46.252.46) by a.mx.sunsite.dk with SMTP; 8 Jul 2005 17:16:31 -0000 Received: from candle.brasslantern.com ([71.116.88.149]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IJB00LF3JZH6DR3@vms046.mailsrvcs.net> for zsh-users@sunsite.dk; Fri, 08 Jul 2005 12:16:30 -0500 (CDT) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j68HGSbc016749 for ; Fri, 08 Jul 2005 10:16:28 -0700 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j68HGRbe016748 for zsh-users@sunsite.dk; Fri, 08 Jul 2005 10:16:27 -0700 Date: Fri, 08 Jul 2005 17:16:27 +0000 From: Bart Schaefer Subject: Re: Help parsing a file from one regex to another In-reply-to: <20050708073037.GB9744@localhost.localdomain> To: zsh-users@sunsite.dk Message-id: <1050708171627.ZM16747@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <20050708073037.GB9744@localhost.localdomain> Comments: In reply to Doug Kearns "Re: Help parsing a file from one regex to another" (Jul 8, 5:30pm) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Jul 8, 5:30pm, Doug Kearns wrote: } Subject: Re: Help parsing a file from one regex to another } } > I am trying to parse a range of data out of a file from one regular } > expression up to another. The input starts with `^@main::FLAGS' and } > goes up to the next `)' I am using awk right now, but it is *ugly* } } flags=( ${=${${${(f)"$(<$tmp_file)"}[(r)@main::FLAGS*,(r)\);]}#*\"}//[^[:upper:][:blank:]]/} ) That only works if the closing paren is on a line by itself, I think. You need (r)*\); in the subscript expression, maybe even (r)*\);* if there may be other stuff following the close-paren. Also, that expression won't work if you replace FLAGS with PRIORITIES, because (r)*\); always matches the end of the FLAGS assignment, which is before the beginning of the PRIORITIES assignment. To extract just the line(s) of interest from the file with sed: sed -n -e '/^@main::FLAGS.*)/{p;q;}' -e '/^@main::FLAGS/,/)/p' If you know that the close paren is never on the same line as the @main then you can eliminate the first -e expression. So to put the whole thing together: flags=( ${${$(sed -n -e '/^@main::FLAGS.*)/{p;q;}' -e '/^@main::FLAGS/,/)/p' <$tmp_file)}//[^[:upper:]]/} ) shift flags # Throw away the word "FLAGS" from @main::FLAGS