Hello,
On Wed, 23 Jan 2019, Adam Carter wrote:
>> $ printf '0.1.2.3 01.2.3.4 1.2.3.0 1.2.000.3\n' | \
>> sed 's/0*\([[:digit:]]\+\)/\1/g'
>> 0.1.2.3 1.2.3.4 1.2.3.0 1.2.0.3
>
>So [[:digit:]] is another way of writing [0-9] and the + just means another
>instance of the proceeding expression,
On 1/23/19 5:52 AM, Wols Lists wrote:
I've just done a bit of digging, and would this work to match an octet?
[0-9][0-9]?[0-9]?
It doesn't match 0123. Regardless, using [0-9] is destined to fail
because it will match things like 999 that also aren't an octet.
On 23/01/19 07:37, Alexander Kapshuk wrote:
> On Wed, Jan 23, 2019 at 9:05 AM Paul Colquhoun
> 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 wrote:
>> François-Xavier
>
> My bad, it should be:
>
On Wed, Jan 23, 2019 at 9:05 AM Paul Colquhoun
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 wrote:
> > >> > François-Xavier
> > >>
> > >> My bad, it should be:
> > >>
> > >> sed 's/0*\([0-9][0-9]*\)/\1/g'
> > >>
On Wednesday, 23 January 2019 5:52:57 PM AEDT Alexander Kapshuk wrote:
> On Wed, Jan 23, 2019 at 5:20 AM Adam Carter 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
On Wed, Jan 23, 2019 at 5:20 AM Adam Carter 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
Le 23/01/2019 à 04:19, Adam Carter a écrit :
> 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
On Wednesday, 23 January 2019 2:32:43 PM AEDT Adam Carter wrote:
> > $ printf '0.1.2.3 01.2.3.4 1.2.3.0 1.2.000.3\n' | \
> >
> > sed 's/0*\([[:digit:]]\+\)/\1/g'
> >
> > 0.1.2.3 1.2.3.4 1.2.3.0 1.2.0.3
>
> Hi David - thanks for that.
>
> So [[:digit:]] is another way of writing [0-9] and
>
> $ printf '0.1.2.3 01.2.3.4 1.2.3.0 1.2.000.3\n' | \
> sed 's/0*\([[:digit:]]\+\)/\1/g'
> 0.1.2.3 1.2.3.4 1.2.3.0 1.2.0.3
>
>
>
Hi David - thanks for that.
So [[:digit:]] is another way of writing [0-9] and the + just means another
instance of the proceeding expression, right, so your and
On Wed, Jan 23, 2019 at 12:34 AM Michael Orlitzky wrote:
> On 1/21/19 9:55 PM, David Haller wrote:
> >
> > $ printf '0.1.2.3 01.2.3.4 1.2.3.0 1.2.000.3\n' | \
> > sed 's/0*\([[:digit:]]\+\)/\1/g'
> > 0.1.2.3 1.2.3.4 1.2.3.0 1.2.0.3
> >
>
> There are actually more than four examples that it
>
> > 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
On 1/21/19 9:55 PM, David Haller wrote:
$ printf '0.1.2.3 01.2.3.4 1.2.3.0 1.2.000.3\n' | \
sed 's/0*\([[:digit:]]\+\)/\1/g'
0.1.2.3 1.2.3.4 1.2.3.0 1.2.0.3
There are actually more than four examples that it needs to work on. And
more to the point, this is going to destroy any other
Hello,
On Mon, 21 Jan 2019, Michael Orlitzky wrote:
>On 1/21/19 6:50 PM, Adam Carter wrote:
>> I need to clean up a file which has IP addresses with leading zeros in
>> some of the octets so I need to make, say, .09 into .9
>>
>> How do i do that in sed/awk/whatever?
>
>The first thing you
Le 22/01/2019 à 03:05, François-Xavier CARTON a écrit :
Le 22/01/2019 à 00:50, Adam Carter a écrit :
I need to clean up a file which has IP addresses with leading zeros in
some of the octets so I need to make, say, .09 into .9
How do i do that in sed/awk/whatever?
I believe that should do:
Le 22/01/2019 à 00:50, Adam Carter a écrit :
I need to clean up a file which has IP addresses with leading zeros in
some of the octets so I need to make, say, .09 into .9
How do i do that in sed/awk/whatever?
I believe that should do:
sed 's/0*\([0-9]\)/\1/g'
eg.
$ sed
On 21/01/2019 18:50, Adam Carter wrote:
> I need to clean up a file which has IP addresses with leading zeros in
> some of the octets so I need to make, say, .09 into .9
>
> How do i do that in sed/awk/whatever?
A regex would be difficult. Parser is what you want.
You could use Python's
On 1/21/19 5:02 PM, Michael Orlitzky wrote:
You need a parser, not a regular expression.
The first thing that came to mind is splitting the values and passing
them through printf.
(You can do it with a regex, but it's going to be one of those comical
twelve-page-long things.)
I don't
On 1/21/19 6:50 PM, Adam Carter wrote:
I need to clean up a file which has IP addresses with leading zeros in
some of the octets so I need to make, say, .09 into .9
How do i do that in sed/awk/whatever?
The first thing you should do is construct a bunch of test cases, with
all of the
I need to clean up a file which has IP addresses with leading zeros in some
of the octets so I need to make, say, .09 into .9
How do i do that in sed/awk/whatever?
19 matches
Mail list logo