From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9318 invoked from network); 21 Jun 2004 18:36:57 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 21 Jun 2004 18:36:57 -0000 Received: (qmail 26632 invoked from network); 21 Jun 2004 18:36:30 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Jun 2004 18:36:30 -0000 Received: (qmail 19133 invoked by alias); 21 Jun 2004 18:36:06 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7581 Received: (qmail 19115 invoked from network); 21 Jun 2004 18:36:06 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 21 Jun 2004 18:36:03 -0000 Received: (qmail 24987 invoked from network); 21 Jun 2004 18:35:30 -0000 Received: from lakermmtao11.cox.net (68.230.240.28) by a.mx.sunsite.dk with SMTP; 21 Jun 2004 18:35:25 -0000 Received: from quark.hightek.org ([68.12.75.33]) by lakermmtao11.cox.net (InterMail vM.6.01.03.02 201-2131-111-104-20040324) with ESMTP id <20040621183457.GCU25349.lakermmtao11.cox.net@quark.hightek.org> for ; Mon, 21 Jun 2004 14:34:57 -0400 Received: by quark.hightek.org (Postfix, from userid 501) id DBA5512422; Mon, 21 Jun 2004 13:35:08 -0500 (CDT) Date: Mon, 21 Jun 2004 13:35:08 -0500 From: Vincent Stemen To: zsh-users@sunsite.dk Subject: Re: [zsh] Extracting Informations from strings Message-ID: <20040621183508.GA58766@quark.hightek.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 On Mon, Jun 21, 2004 at 10:24:16AM +0300, Artur Penttinen wrote: > On Mon, 21 Jun 2004, Stefan [iso-8859-1] Reich?r wrote: > > > Date: Mon, 21 Jun 2004 09:02:44 +0200 > > From: "Stefan [iso-8859-1] Reich?r" > > To: zsh-users@sunsite.dk > > Subject: [zsh] Extracting Informations from strings > > > > Hi! > > > > I want to parse the output from acpi: > > Battery 1: charging, 95%, charging at zero rate - will never fully charge. > > > > I want to extract the "95%" from the output above. > > > > How can I achieve this from within zsh? > > # print "Battery 1: charging, 95%, charging at zero rate - will never fully charge." | cut -d, -f2 > 95% > # > > -- > artur penttinen You can also do this directly without calling cut. output="Battery 1: charging, 95%, charging at zero rate - will never fully charge." output=${${=output}[4]} # Split $output and extract the 4th field print ${output%,} # Remove the comma -- Vincent Stemen Avoid the VeriSign/Network Solutions domain registration trap! Read how Network Solutions (NSI) was involved in stealing our domain name. http://www.InetAddresses.net