From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28048 invoked by alias); 1 May 2015 17:34:05 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20174 Received: (qmail 17720 invoked from network); 1 May 2015 17:33:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=QnbJY3qOekxDSVNKunRvnnaWQ+7uB0eFNvDpeIYSlv4=; b=EAtLU7JX1A+4Dmbqo/lE4uj2qGVehhASfg1BfFeILapIgAnjau+xWX87SI79WlWJ9/ GNIeeiK0PuTAWws1o+61gN+29/0ZXu91Ktqw8z4tYpqRYoPaGofA6y1K2CoOo2lOApWq +urwvQmMsKOynvrqGZSJPDmOMpBQJ66xXhGPTUx67VEABub30XctEylQ9Vf0lh3Nl2kl xGXY1ev8Qmn3oCUsxJQTyoYHT5KYHCwfQioUYRndhCUP3LKoQJjEbD/30djnvg10tyx/ vZJG2VC6ExEcpHutG77C8tu3efHwaAUfkfPF/+OIhwuM3nvEqjYA//N+PZ0+VupjocwG UvvA== X-Gm-Message-State: ALoCoQkRtfsEuMoTAuA+DaPe/zgeLP1TgWT5T1a44x75I1g+873re7spwDI6r4Ajy1+Gags2RUwg X-Received: by 10.60.174.33 with SMTP id bp1mr8606665oec.19.1430501629203; Fri, 01 May 2015 10:33:49 -0700 (PDT) From: Bart Schaefer Message-Id: <150501103346.ZM3354@torch.brasslantern.com> Date: Fri, 1 May 2015 10:33:46 -0700 In-Reply-To: Comments: In reply to zzapper "Parse apache error_log" (May 1, 3:41pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Parse apache error_log MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On May 1, 3:41pm, zzapper wrote: } Subject: Parse apache error_log } } Hi } Don't know if this is a job for zsh or sed etc I'd probably do it in perl because you need to both parse the text and build up a data structure of results grouped by one of the fields. } Format:- } [Fri May 01 16:25:05 2015] [error] [client 172.18.158.61] PHP Parse error: } syntax error, unexpected T_VARIABLE } } I want to grab the date-time of the last entry and then display all the } entries with the same date-time. The approach I would take is to create a hash keyed on the date string with each value an array of error messages. As each line is parsed, push it onto the array for the date key. You can't easily do that in zsh (though you could just append to a text string). However, if the file is small enough that it's OK to scan it multiple times, you can make one pass to find the date string you care about and then a second pass, probably with fgrep, to extract all the lines that have that timestamp. It sort of depends on what you want to do with the results after you have collected them. If you're just going to output them, perl may be more than you need.