csh use of grep | tr commands

Aryeh Friedman aryeh.friedman at gmail.com
Mon Aug 10 06:57:20 UTC 2020


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

> On Sun, 9 Aug 2020 21:35:12 -0400
> Aryeh Friedman <aryeh.friedman at gmail.com> wrote:
>
> > On Sun, Aug 9, 2020 at 9:27 PM Robert Huff <roberthuff at rcn.com> wrote:
> >
> > > Ernie Luzar writes:
> > >
> > > >  Double quotes are giving me trouble.
> > > >
> > > >  I have a file with a line in it like this
> > > >  ip4="10.111.098.2"
> > > >  I want to get just the ip address
> ...
> > >         Would awk perhaps be a better tool?
> > >
> >
> > Complete overkill for what he wants to do.
> >
> > He wants to bang a nail in thus only needs a hammer he does not need a
> > nail gun for only one nail.
>
> <fx: click>I'll just pack the perl interpreter up again then</fx>
>
>         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

>
> --
> Steve O'Hara-Smith <steve at sohara.org>
>


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


More information about the freebsd-questions mailing list