This sounds like a really banal question, and it's bugging me dearly.
I have a text file, generated by python, that contains a list of host names and ip addresses in the following format:
host46.provider.com = 192.168.0.1
However, because the file was generated asynchronously, there's a few strange errors in the output. I'm getting lines that look like this:
us9831.provider.com = 262.99.124.183us9832.provider.com = 121.92.213.10
The problem is that it hasn't inserted a newline between the two instances. I've ascertained that (fortunately) the naming convention of the nodes doesn't allow for a number to come before a letter, unless it's before a dot (.
)
So what I neeed to happen is:
- find an instance where a number comes before a dot
- add a newline between the two
I can't figure out how I'll get sed
to maintain the regex match, and copy that over to the next regex.
I've tried this:
cat eg | sed '/[0-9][a-z]/s/[0-9][a-z]/[0-9]\n[a-z]/'
and I have tried this:
cat eg | sed "s/[0-9][a-z]/\n/"
Is sed
the right tool? Should I be using awk
?
Any suggestions would be warmly welcomed.
unless it's before a dot (.)
part of the statementdoesn't allow for a number to come before a letter, unless it's before a dot (.)
is confusing. Why isn'tdoesn't allow for a number to come before a letter
enough? What does a number before a letter that's also a dot (or whatever that means) look like?