csh use of grep | tr commands

Aryeh Friedman aryeh.friedman at gmail.com
Mon Aug 10 07:18:25 UTC 2020


On Mon, Aug 10, 2020 at 3:09 AM Steve O'Hara-Smith <steve at sohara.org> wrote:

> On Mon, 10 Aug 2020 02:57:07 -0400
> Aryeh Friedman <aryeh.friedman at gmail.com> wrote:
>
> > On Mon, Aug 10, 2020 at 2:41 AM Steve O'Hara-Smith <steve at 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


More information about the freebsd-questions mailing list