zsh-users
 help / color / mirror / code / Atom feed
From: Vincent Stemen <zsh@hightek.org>
To: zsh-users@sunsite.dk
Subject: Re: [zsh] Extracting Informations from strings
Date: Mon, 21 Jun 2004 13:35:08 -0500	[thread overview]
Message-ID: <20040621183508.GA58766@quark.hightek.org> (raw)
In-Reply-To: <Pine.LNX.4.60.0406211022520.30334@znvy.uxvyno.rzvpargjbexf.pbz>

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" <xsteve@riic.at>
> > 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


  reply	other threads:[~2004-06-21 18:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-21  7:02 Stefan Reichör
2004-06-21  7:24 ` [zsh] " Artur Penttinen
2004-06-21 18:35   ` Vincent Stemen [this message]
2004-06-21  9:33 ` Peter Stephenson
2004-06-21 16:28   ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040621183508.GA58766@quark.hightek.org \
    --to=zsh@hightek.org \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).