I have the following file:
proto udp
resolv-retry infinite
nobind
#Single line of those bellow, I've added multiple for variations of it
remote fi.server.com 50505
remote us-cityone.server.com 5050
remote uk-citytwo.server.com 50500
remote us-citythree.server.com 56546
remote sweden.server.com 6546546
rest of config file..
Let me be more clear, this is a OpenVPN conf file. I want to replace only that line that starts with remote servername 5555
- server name a different one.
I've added multiple remote servername 5555
lines just for an example, because they all represent variations that I might occur.
I want to match middle column only, fi.server.com
, us-newyorkcity.server.com
etc and replace it using sed
with different name.
Why pattern like this, doesn't work?
sed -i.bak 's/\w+(-|\.)\.?\w+\.?\.com/g' filename
I've tried this one as well..
sed -i.bak 's/\w+(-|\.)\.?\w+\.?\.\w+/g' filename
Further note, from the example us-newyorkcity.server.com
only server.com
part is a static one. Rest is changed.
Thanks for help!
only server.com part is a static one. Rest is changed.
How do you want it changed ? – Sergiy Kolodyazhnyy Feb 9 '17 at 3:24