Reputation: 1026
I created the following regex which I am able to successfully use to grab a substring, but not to substitute it with sed.
test@devs-ops01:~$ grep -Eo "server\shost-gso121.*?:[0-9]{4}\s;" upstream_clusters.conf
server host-gso121.domain.com:8080 ;
When I try to use the same regex in sed, it doesn't catch it:
test@devs-ops01:~$ sed 's/server\shost-gso121.*?:[0-9]{4}\s;//' upstream_clusters.conf
upstream service_cluster {
server host-gso120.domain.com:8080 ;server host-gso121.domain.com:8080 ;
keepalive 8;
}
And yet, if i just write the name of the server without all of the special functions, the sed command does catch it:
test@devs-ops01:~$ sed 's/host-gso121//' upstream_clusters.conf
upstream service_cluster {
server host-gso120.domain.com:8080 ;server .domain.com:8080 ;
keepalive 8;
}
Any suggestions greatly appreciated!
Upvotes: 1
Views: 448