Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-26 Thread Kai Peter
On 2019-01-25 18:31, Michael Orlitzky wrote: On 1/25/19 11:32 AM, Kai Peter wrote: Really interesting _how_ people think. Find the error: You're not even trying: $ echo 0.0.0.0 | sed 's/\.0/\./g' | sed 's/^0//g' | \ sed 's/\.0/\./g' | sed 's/\.\./.0./g' | sed 's/^0//g' .0.. True,

Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-25 Thread Michael Orlitzky
On 1/25/19 11:32 AM, Kai Peter wrote: > > Really interesting _how_ people think. Find the error: > You're not even trying: $ echo 0.0.0.0 | sed 's/\.0/\./g' | sed 's/^0//g' | \ sed 's/\.0/\./g' | sed 's/\.\./.0./g' | sed 's/^0//g' .0.. It's trivial to enumerate all "valid" (that is,

Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-25 Thread Kai Peter
On 2019-01-24 17:40, Michael Orlitzky wrote: On 1/24/19 4:00 AM, Gerrit Kühn wrote: --- [me@you ~]# ip=01.02.00.0004; for d in $(echo "${ip}"|tr '.' '\n'); do myip="${myip}"$(printf "%i" "${d}")"." ; done; echo ${myip%.} 1.2.0.4 That turns "010" into "8". Using a real programming language

Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-24 Thread Michael Orlitzky
On 1/24/19 4:00 AM, Gerrit Kühn wrote: --- [me@you ~]# ip=01.02.00.0004; for d in $(echo "${ip}"|tr '.' '\n'); do myip="${myip}"$(printf "%i" "${d}")"." ; done; echo ${myip%.} 1.2.0.4 That turns "010" into "8". Using a real programming language with a parser is only heavyweight compared to

Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-24 Thread Gerrit Kühn
On Wed, 23 Jan 2019 16:45:59 -0500 Michael Orlitzky wrote about Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit: > > This is not a good application for a regex. > Since that doesn't seem to be stopping anyone, here's my entry. Since the only alternative to

Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-23 Thread Michael Orlitzky
On 1/23/19 2:24 PM, Grant Edwards wrote: This is not a good application for a regex. Since that doesn't seem to be stopping anyone, here's my entry. sed

[gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-23 Thread Grant Edwards
On 2019-01-23, Alexander Kapshuk wrote: > On Wed, Jan 23, 2019 at 9:41 PM Grant Edwards > wrote: >> On 2019-01-23, Alexander Kapshuk wrote: >> >> > This any better? :-) >> > >> > echo '198.088.0.01 >> > 198.088.062.01 >> > 198.088.0.001' | sed -r 's/\.0+([^.0]+)/.\1/g' >> >> I guess it's

Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-23 Thread Michael Orlitzky
On 1/23/19 3:08 PM, Alexander Kapshuk wrote: The OP stated that there were no leading zeros in the first octet of the IP address, so that case did not need to be handled. $ echo "1.00.3.4" | sed -r 's/\.0+([^.0]+)/.\1/g' 1.00.3.4

Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-23 Thread Alexander Kapshuk
On Wed, Jan 23, 2019 at 9:41 PM Grant Edwards wrote: > > On 2019-01-23, Alexander Kapshuk wrote: > > > This any better? :-) > > > > echo '198.088.0.01 > > 198.088.062.01 > > 198.088.0.001' | sed -r 's/\.0+([^.0]+)/.\1/g' > > I guess it's 'better', but it's still broken: > > $ echo '003.4.5.6' |

[gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-23 Thread Grant Edwards
On 2019-01-23, Alexander Kapshuk wrote: > This any better? :-) > > echo '198.088.0.01 > 198.088.062.01 > 198.088.0.001' | sed -r 's/\.0+([^.0]+)/.\1/g' I guess it's 'better', but it's still broken: $ echo '003.4.5.6' | sed -r 's/\.0+([^.0]+)/.\1/g' 003.4.5.6 This is not a good application for

Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-23 Thread Alexander Kapshuk
On Wed, Jan 23, 2019 at 4:10 PM Grant Edwards wrote: > > On 2019-01-23, Alexander Kapshuk wrote: > > > > 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 > > Also no. > > $ echo 198.088.0.001 | sed

Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-23 Thread Kai Peter
On 2019-01-23 18:26, Neil Bothwick wrote: On Wed, 23 Jan 2019 14:09:45 - (UTC), Grant Edwards wrote: > 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 Also no. $ echo 198.088.0.001 | sed

Re: [gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-23 Thread Neil Bothwick
On Wed, 23 Jan 2019 14:09:45 - (UTC), Grant Edwards wrote: > > 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 > > Also no. > > $ echo 198.088.0.001 | sed 's/\.0\([0-9][0-9]*\)/.\1/g' > 198.88.0.01

[gentoo-user] Re: OT scripting - strip zero if between period and digit

2019-01-23 Thread Grant Edwards
On 2019-01-23, Alexander Kapshuk wrote: > > 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 Also no. $ echo 198.088.0.001 | sed 's/\.0\([0-9][0-9]*\)/.\1/g' 198.88.0.01 -- Grant Edwards grant.b.edwards