I've got the following bash command, which does remove a leading zero.. but it also removes a single zero which is wrong.
echo $ip | sed 's/\.0\{1,2\}/\./g' | sed 's/^0\{1,2\}//'
if $ip is 192.168.1.01 the result should be 192.168.1.1
if $ip is 192.168.01.01 the result should be 192.168.1.1
if $ip is 192.168.0.01 the result should be 192.168.0.1
if $ip is 192.168.0.0 the result should be 192.168.0.0
etc
What I'm getting is 192.168.0.0 becomes 192.168.. or 192.168.0.01 becomes 192.168..1
Any idea how to do this ?
Thanks