Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [zsh] Extracting Informations from strings
- X-seq: zsh-users 7581
- From: Vincent Stemen <zsh@xxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: [zsh] Extracting Informations from strings
- Date: Mon, 21 Jun 2004 13:35:08 -0500
- In-reply-to: <Pine.LNX.4.60.0406211022520.30334@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <w4dzn6xmm0b.fsf@xxxxxxxxxxxxxxxxxxxxxxxxx> <Pine.LNX.4.60.0406211022520.30334@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxx>
> > To: zsh-users@xxxxxxxxxx
> > 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author