Gentoo Archives: gentoo-user

From: Kai Peter <kp@×××××××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit
Date: Fri, 25 Jan 2019 16:33:24
Message-Id: ac31991115498b1c7fde5d0b4da5a7cd@lists.openqmail.org
In Reply to: Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit by Michael Orlitzky
1 On 2019-01-24 17:40, Michael Orlitzky wrote:
2 > On 1/24/19 4:00 AM, Gerrit Kühn wrote:
3 >>
4 >> ---
5 >> [me@you ~]# ip=01.02.00.0004; for d in $(echo "${ip}"|tr '.' '\n');
6 >> do myip="${myip}"$(printf "%i" "${d}")"." ; done; echo ${myip%.}
7 >> 1.2.0.4
8 >
9 > That turns "010" into "8". Using a real programming language with a
10 > parser is only heavyweight compared to solutions that don't work.
11 >
12 > $ ip=01.02.00.010; for d in $(echo "${ip}"|tr '.' '\n'); \
13 > do myip="${myip}"$(printf "%i" "${d}")"." ; done; echo ${myip%.}
14 > 1.2.0.8
15 Really interesting _how_ people think. Find the error:
16
17 echo 01.02.00.010 | sed 's/\.0/\./g' | sed 's/^0//g' | sed 's/\.0/\./g'
18 | sed 's/\.\./.0./g' | sed 's/^0//g'
19
20
21
22 --
23 Sent with eQmail-1.11 beta - a fork of djb's famous qmail

Replies