csh use of grep | tr commands

Aryeh Friedman aryeh.friedman at gmail.com
Mon Aug 10 00:40:58 UTC 2020


On Sun, Aug 9, 2020 at 8:35 PM Ernie Luzar <luzar722 at gmail.com> wrote:

> 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
>
> ip=`grep "ip4=" directory-path/file-name
>
> $ip ends up having ip4="10.111.098.2"  in it
>
> ip=`echo -n "${ip}" | tr -d "ip4="
>
> $ip ends up having "10.111.098.2"  in it
>
> Putting | tr """ " "` after the echo above gives error.
>
> How do I remove the " around the ip address?
>

tr -d '"'

for example:

Desktop at neomarx% cat foo
ip4="0.0.0.0"
somethingelse="fred"
Desktop at neomarx% cat foo | grep ip4 | cut -f2 -d'=' | tr -d '"'
0.0.0.0


More information about the freebsd-questions mailing list