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 's/0*\([0-9]\)/\1/g' <<EOF
0.1.2.3
01.2.3.4
1.2.3.0
1.2.000.3
EOF
0.1.2.3
1.2.3.4
1.2.3.0
1.2.0.3

François-Xavier

Reply via email to