Gentoo Archives: gentoo-user

From: Michael Orlitzky <mjo@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit
Date: Thu, 24 Jan 2019 16:40:38
Message-Id: f533ebb9-e40a-e4ab-c45e-01cbe76b3fc5@gentoo.org
In Reply to: Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit by "Gerrit Kühn"
1 On 1/24/19 4:00 AM, Gerrit Kühn wrote:
2 >
3 > ---
4 > [me@you ~]# ip=01.02.00.0004; for d in $(echo "${ip}"|tr '.' '\n');
5 > do myip="${myip}"$(printf "%i" "${d}")"." ; done; echo ${myip%.}
6 > 1.2.0.4
7
8 That turns "010" into "8". Using a real programming language with a
9 parser is only heavyweight compared to solutions that don't work.
10
11 $ ip=01.02.00.010; for d in $(echo "${ip}"|tr '.' '\n'); \
12 do myip="${myip}"$(printf "%i" "${d}")"." ; done; echo ${myip%.}
13 1.2.0.8

Replies

Subject Author
Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit Kai Peter <kp@×××××××××××××××.org>