Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Aug 2020 19:56:03 +1000
From:      Ragnar Johanson <ragnar@iinet.net.au>
To:        freebsd-questions@freebsd.org
Subject:   Re: csh use of grep | tr  commands
Message-ID:  <20200811195603.1d0a7283@xinu.fritz.box>
In-Reply-To: <20200810164924.4ec11e74.freebsd@edvax.de>
References:  <5F30962B.5060005@gmail.com> <24368.41568.96908.196223@jerusalem.litteratus.org> <20200810164924.4ec11e74.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 10 Aug 2020 16:49:24 +0200
Polytropon <freebsd@edvax.de> hacked into the keyboard:

> On Sun, 9 Aug 2020 21:26:56 -0400, Robert Huff wrote:
> > Ernie Luzar writes:

> > >  How do I remove the " around the ip address?  
> > 
> > 	Would awk perhaps be a better tool?  
> 
> Possibly. But it's more elaborate than sed. :-)
> 
> 	% echo 'ip4="10.111.098.2"' | awk '/^ip4=/ { gsub("ip4=", "", $0);
> gsub("\"", "", $0); print $0 }' 10.111.098.2
> 

There is also a shorter awk solution:

% echo 'ip4="10.111.098.2"' | awk -F'"' '/^ip4/ {print $2}'
10.111.098.2


-- 
Ragnar Johanson                                 Darwin/macOS
ragnar[at]iinet[flyspeck]net[flyspeck]au
Please no HTML or proprietary data in email!   
GPGkeyID: 6AC1 3E9A 39E1 8590 D1A2  C92C 93F4 2856 4C79 CB89
.




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