Date: Mon, 10 Aug 2020 15:56:51 +0100 From: Arthur Chance <freebsd@qeng-ho.org> To: Ernie Luzar <luzar722@gmail.com>, "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: Re: csh use of grep | tr commands Message-ID: <adfce1c0-3b80-ad5c-cda6-eb919886c1b5@qeng-ho.org> In-Reply-To: <5F30962B.5060005@gmail.com> References: <5F30962B.5060005@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 10/08/2020 01:34, Ernie Luzar 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? Provided you're using sh (or bash) for your script eval $(grep -e '^ip4=' /path/name) will set the variable ip4 to the address. Try echo $ip4 afterwards to see. -- The number of people predicting the demise of Moore's Law doubles every 18 months.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?adfce1c0-3b80-ad5c-cda6-eb919886c1b5>