csh use of grep | tr commands
Ragnar Johanson
ragnar at iinet.net.au
Tue Aug 11 09:56:14 UTC 2020
On Mon, 10 Aug 2020 16:49:24 +0200
Polytropon <freebsd at 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
.
More information about the freebsd-questions
mailing list