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 possible input representations and what you think the output 
representation should be. Then, you should write a program in something 
other than bash that passes all of the test cases. It's not as easy as 
it sounds; for example:
  * What happens to 0.1.2.3?

  * What happens to 01.2.3.4?

  * What happens to 1.2.3.0?

  * What happens to 1.2.000.3?

You need a parser, not a regular expression. (You can do it with a regex, but it's going to be one of those comical twelve-page-long things.)


Reply via email to