Gentoo Archives: gentoo-user

From: Adam Carter <adamcarter3@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] OT scripting - strip zero if between period and digit
Date: Wed, 23 Jan 2019 03:20:10
Message-Id: CAC=wYCGiwR8Fa=T9qmfRnxx2DQTApLcMiBHoh6husgGPz5D9DA@mail.gmail.com
In Reply to: Re: [gentoo-user] OT scripting - strip zero if between period and digit by "François-Xavier CARTON"
1 >
2 > > François-Xavier
3 > >
4 > >
5 >
6 > My bad, it should be:
7 >
8 > sed 's/0*\([0-9][0-9]*\)/\1/g'
9 >
10 > (tests are indeed needed!)
11 >
12
13 Many thanks François. This is almost right, but it is also stripping zeros
14 that follow a letter, and I only want it to strip zeros that are proceeded
15 by a period. There are no leading zeros in the first octet of the IP so
16 that case does not need to be handled.
17
18 Does the \1 refer to what's in the ()'s? So anything that one would wont to
19 carry through should be inside the ()'s and anything that's outside is
20 stripped, right?

Replies

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