On Wed, Jan 23, 2019 at 9:05 AM Paul Colquhoun
<paul...@andor.dropbear.id.au> wrote:
>
> On Wednesday, 23 January 2019 5:52:57 PM AEDT Alexander Kapshuk wrote:
> > On Wed, Jan 23, 2019 at 5:20 AM Adam Carter <adamcart...@gmail.com> wrote:
> > >> > François-Xavier
> > >>
> > >> My bad, it should be:
> > >>
> > >> sed 's/0*\([0-9][0-9]*\)/\1/g'
> > >>
> > >> (tests are indeed needed!)
> > >
> > > 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.
> > >
> > > 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?
> > Would something like to do the trick?
> > echo 198.088.062.01 | sed 's/\.0/./g'
> > 198.88.62.1
>
> In a word, no.
>
> echo 198.088.0.01 | sed 's/\.0/./g'
> 198.88..1
>
>
> --
> Reverend Paul Colquhoun, ULC.     http://andor.dropbear.id.au/
>   Asking for technical help in newsgroups?  Read this first:
>      http://catb.org/~esr/faqs/smart-questions.html#intro
>
>
>
>

How about this one?

echo '198.088.0.01
198.088.062.01' | sed 's/\.0\([0-9][0-9]*\)/.\1/g'
198.88.0.1
198.88.62.1

Reply via email to