Gentoo Archives: gentoo-user

From: Alexander Kapshuk <alexander.kapshuk@×××××.com>
To: Gentoo mailing list <gentoo-user@l.g.o>
Subject: Re: [gentoo-user] OT scripting - strip zero if between period and digit
Date: Wed, 23 Jan 2019 06:53:43
Message-Id: CAJ1xhMX7H4GGU_Uo+867qbVbwes6=xLztPSnDBGjUkeEQFoyLQ@mail.gmail.com
In Reply to: Re: [gentoo-user] OT scripting - strip zero if between period and digit by Adam Carter
1 On Wed, Jan 23, 2019 at 5:20 AM Adam Carter <adamcarter3@×××××.com> wrote:
2 >>
3 >> > François-Xavier
4 >> >
5 >> >
6 >>
7 >> My bad, it should be:
8 >>
9 >> sed 's/0*\([0-9][0-9]*\)/\1/g'
10 >>
11 >> (tests are indeed needed!)
12 >
13 >
14 > Many thanks François. This is almost right, but it is also stripping zeros that follow a letter, and I only want it to strip zeros that are proceeded by a period. There are no leading zeros in the first octet of 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 to carry through should be inside the ()'s and anything that's outside is stripped, right?
17 >
18 >
19 >
20
21 Would something like to do the trick?
22 echo 198.088.062.01 | sed 's/\.0/./g'
23 198.88.62.1

Replies

Subject Author
Re: [gentoo-user] OT scripting - strip zero if between period and digit Paul Colquhoun <paulcol@×××××××××××××××××.au>