From owner-freebsd-questions@freebsd.org Mon Aug 10 14:57:01 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2F41A3A594E for ; Mon, 10 Aug 2020 14:57:01 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Received: from bede.qeng-ho.org (bede.qeng-ho.org [217.155.128.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4BQJvv2tNGz4Nd8 for ; Mon, 10 Aug 2020 14:56:59 +0000 (UTC) (envelope-from freebsd@qeng-ho.org) Received: from arthur.home.qeng-ho.org (arthur.home.qeng-ho.org [172.23.1.2]) by bede.qeng-ho.org (Postfix) with ESMTP id 23AFE1063C; Mon, 10 Aug 2020 15:56:52 +0100 (BST) Subject: Re: csh use of grep | tr commands To: Ernie Luzar , "freebsd-questions@freebsd.org" References: <5F30962B.5060005@gmail.com> From: Arthur Chance Message-ID: Date: Mon, 10 Aug 2020 15:56:51 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <5F30962B.5060005@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4BQJvv2tNGz4Nd8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of freebsd@qeng-ho.org designates 217.155.128.241 as permitted sender) smtp.mailfrom=freebsd@qeng-ho.org X-Spamd-Result: default: False [-2.88 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.05)[-1.053]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:217.155.128.240/29]; NEURAL_HAM_LONG(-0.98)[-0.983]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[qeng-ho.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.55)[-0.546]; RCPT_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[gmail.com,freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:13037, ipnet:217.155.0.0/16, country:GB]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Aug 2020 14:57:01 -0000 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.