Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Aug 2020 03:18:12 -0400
From:      Aryeh Friedman <aryeh.friedman@gmail.com>
To:        "Steve O'Hara-Smith" <steve@sohara.org>
Cc:        Robert Huff <roberthuff@rcn.com>, Ernie Luzar <luzar722@gmail.com>,  "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: csh use of grep | tr commands
Message-ID:  <CAGBxaXmp9SpmOg9DUoK1YCbvA7zxEFD0Lym91ScBVh3xWHoCmg@mail.gmail.com>
In-Reply-To: <20200810080928.74df05790dd6676439ad750c@sohara.org>
References:  <5F30962B.5060005@gmail.com> <24368.41568.96908.196223@jerusalem.litteratus.org> <CAGBxaX=%2B6Lji_zDUKTvrq4Kdo%2BM1jFDjLtDpTuU_Ue1Q_VJ3AQ@mail.gmail.com> <20200810074135.c76402a37676b5d2bf03b851@sohara.org> <CAGBxaX=5v0_HQMj_%2Bubt_dgnbzw5L8DyNdHzR9k433hfkNg8mw@mail.gmail.com> <20200810080928.74df05790dd6676439ad750c@sohara.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Aug 10, 2020 at 3:09 AM Steve O'Hara-Smith <steve@sohara.org> wrote:

> On Mon, 10 Aug 2020 02:57:07 -0400
> Aryeh Friedman <aryeh.friedman@gmail.com> wrote:
>
> > On Mon, Aug 10, 2020 at 2:41 AM Steve O'Hara-Smith <steve@sohara.org>
> > wrote:
> >
> > >         Seriously though I'd go with cut.
> > >
> > > $ echo 'ip4="10.111.098.2"' | cut -d\" -f2
> > > 10.111.098.2
> > >
> >
> > Only problem doesn't handle the case where you might have multiple quoted
> > values on the line where is cut -f2 -d'='|tr -d '"' does
>
>         Agreed - but since we know it's a quoted IP address we can save a
> process.
>

In foo:
ip4_ifaces="re0:192.168.11.60" "lo0:127.0.0.1"

foreach i (`grep ip4 foo|cut -f2 -d'='|tr -d '"')
    ifconfig `echo $i|cut -f1-2 -d':'`
end


> --
> Steve O'Hara-Smith                          |   Directable Mirror Arrays
> C:\>WIN                                     | A better way to focus the sun
> The computer obeys and wins.                |    licences available see
> You lose and Bill collects.                 |    http://www.sohara.org/
>


-- 
Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGBxaXmp9SpmOg9DUoK1YCbvA7zxEFD0Lym91ScBVh3xWHoCmg>