Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Aug 2020 08:52:08 -0600
From:      "@lbutlr" <kremels@kreme.com>
To:        FreeBSD <freebsd-questions@freebsd.org>
Subject:   Re: csh use of grep | tr  commands
Message-ID:  <B7563349-4256-4991-A2F6-39608214225E@kreme.com>
In-Reply-To: <20200810164453.378835aa.freebsd@edvax.de>
References:  <5F30962B.5060005@gmail.com> <20200810164453.378835aa.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On 10 Aug 2020, at 08:44, Polytropon <freebsd@edvax.de> wrote:
> On Sun, 09 Aug 2020 20:34:51 -0400, Ernie Luzar wrote:
>> Double quotes are giving me trouble.
>>=20
>> I have a file with a line in it like this
>> ip4=3D"10.111.098.2"
>> I want to get just the ip address
>>=20
>> ip=3D`grep "ip4=3D" directory-path/file-name
>>=20
>> $ip ends up having ip4=3D"10.111.098.2"  in it
>>=20
>> ip=3D`echo -n "${ip}" | tr -d "ip4=3D"
>>=20
>> $ip ends up having "10.111.098.2"  in it
>>=20
>> Putting | tr """ " "` after the echo above gives error.
>>=20
>> How do I remove the " around the ip address?
>=20
> Without any insult: You're using the wrong tool.
>=20
> While the C shell is acceptable as an interactive shell
> (and I even prefer it over bash to a certain degree),
> it's absolutely terrible, and I may even say unsuited
> for scripting.

I agree. My first use of a unix system defaulted to csh. As soon as I =
started writing scripts I switched away from csh. (bash and now zsh).

> The system's default scripting shell is sh. Use that.

Or that.

> % echo 'those "are" quotes' | sed 's/"//g'

Exactly what I would do, though I sometimes I use egrep -o if there is =
longer input.

--=20
I WILL NOT SELL LAND IN FLORIDA Bart chalkboard Ep. 7F16




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B7563349-4256-4991-A2F6-39608214225E>