Gentoo Archives: gentoo-user

From: Alexander Kapshuk <alexander.kapshuk@×××××.com>
To: Gentoo mailing list <gentoo-user@l.g.o>
Subject: Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit
Date: Wed, 23 Jan 2019 20:08:05
Message-Id: CAJ1xhMXGHZQhO=DGa+0=6fcaf1nafabUdxc-NaGU5hsiHnmoeg@mail.gmail.com
In Reply to: [gentoo-user] Re: OT scripting - strip zero if between period and digit by Grant Edwards
1 On Wed, Jan 23, 2019 at 9:41 PM Grant Edwards <grant.b.edwards@×××××.com> wrote:
2 >
3 > On 2019-01-23, Alexander Kapshuk <alexander.kapshuk@×××××.com> wrote:
4 >
5 > > This any better? :-)
6 > >
7 > > echo '198.088.0.01
8 > > 198.088.062.01
9 > > 198.088.0.001' | sed -r 's/\.0+([^.0]+)/.\1/g'
10 >
11 > I guess it's 'better', but it's still broken:
12 >
13 > $ echo '003.4.5.6' | sed -r 's/\.0+([^.0]+)/.\1/g'
14 > 003.4.5.6
15 >
16 > This is not a good application for a regex.
17 >
18 > --
19 > Grant Edwards grant.b.edwards Yow! I have accepted
20 > at Provolone into my life!
21 > gmail.com
22 >
23 >
24 The OP stated that there were no leading zeros in the first octet of
25 the IP address, so that case did not need to be handled.

Replies