Gentoo Archives: gentoo-user

From: Grant Edwards <grant.b.edwards@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: OT scripting - strip zero if between period and digit
Date: Wed, 23 Jan 2019 19:42:02
Message-Id: q2af1h$7oih$1@blaine.gmane.org
In Reply to: Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit by Alexander Kapshuk
1 On 2019-01-23, Alexander Kapshuk <alexander.kapshuk@×××××.com> wrote:
2
3 > This any better? :-)
4 >
5 > echo '198.088.0.01
6 > 198.088.062.01
7 > 198.088.0.001' | sed -r 's/\.0+([^.0]+)/.\1/g'
8
9 I guess it's 'better', but it's still broken:
10
11 $ echo '003.4.5.6' | sed -r 's/\.0+([^.0]+)/.\1/g'
12 003.4.5.6
13
14 This is not a good application for a regex.
15
16 --
17 Grant Edwards grant.b.edwards Yow! I have accepted
18 at Provolone into my life!
19 gmail.com

Replies