Gentoo Archives: gentoo-user

From: Paul Colquhoun <paulcol@×××××××××××××××××.au>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] OT scripting - strip zero if between period and digit
Date: Wed, 23 Jan 2019 07:05:34
Message-Id: 1807215.rGlK2TTOW4@bluering
In Reply to: Re: [gentoo-user] OT scripting - strip zero if between period and digit by Alexander Kapshuk
1 On Wednesday, 23 January 2019 5:52:57 PM AEDT Alexander Kapshuk wrote:
2 > On Wed, Jan 23, 2019 at 5:20 AM Adam Carter <adamcarter3@×××××.com> wrote:
3 > >> > François-Xavier
4 > >>
5 > >> My bad, it should be:
6 > >>
7 > >> sed 's/0*\([0-9][0-9]*\)/\1/g'
8 > >>
9 > >> (tests are indeed needed!)
10 > >
11 > > Many thanks François. This is almost right, but it is also stripping zeros
12 > > that follow a letter, and I only want it to strip zeros that are
13 > > proceeded by a period. There are no leading zeros in the first octet of
14 > > the IP so that case does not need to be handled.
15 > >
16 > > Does the \1 refer to what's in the ()'s? So anything that one would wont
17 > > to carry through should be inside the ()'s and anything that's outside is
18 > > stripped, right?
19 > Would something like to do the trick?
20 > echo 198.088.062.01 | sed 's/\.0/./g'
21 > 198.88.62.1
22
23 In a word, no.
24
25 echo 198.088.0.01 | sed 's/\.0/./g'
26 198.88..1
27
28
29 --
30 Reverend Paul Colquhoun, ULC. http://andor.dropbear.id.au/
31 Asking for technical help in newsgroups? Read this first:
32 http://catb.org/~esr/faqs/smart-questions.html#intro

Replies

Subject Author
Re: [gentoo-user] OT scripting - strip zero if between period and digit Alexander Kapshuk <alexander.kapshuk@×××××.com>