Reputation: 17407
I have this file containing following text.
200.200.200.253
80/tcp:filtered:http
443/tcp:filtered:https
200.200.200.254
80/tcp:filtered:http
443/tcp:filtered:https
web.example.com (200.200.200.250)
80/tcp:filtered:http
443/tcp:filtered:https
I want to use sed to add (:) in end of the IP addresses. so it will look like following.
200.200.200.253 :
80/tcp:filtered:http
443/tcp:filtered:https
200.200.200.254 :
80/tcp:filtered:http
443/tcp:filtered:https
web.example.com (200.200.200.250) :
80/tcp:filtered:http
443/tcp:filtered:https
I am having issue with web.example.com (200.200.200.250)
regex match.
I want this line look like web.example.com (200.200.200.250) :
I got answer this is what i tried.
sed -e 's/[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}/&:/' file.txt
Upvotes: 1
Views: 384
Reputation: 43673
I suggest you to use
sed -r 's/^([0-9]+\.){3}[0-9]+$/& :/g' filename
sed -r 's/([0-9]+\.){3}[0-9]+.*/& :/g' filename
Upvotes: 2