On Wed, 23 Jan 2019 16:45:59 -0500 Michael Orlitzky <[email protected]> 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 a regexp presented so far was using python
(which has been considered a bit heavy-weight), I'll suggest some hacky
shell code instead (here as a one-liner, would probably be nicer to do this
as a function):
---
[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
---
HTH
Gerrit