T
T
taaadm2016-03-02 08:02:07
linux
taaadm, 2016-03-02 08:02:07

Why doesn't regex replacement work with sed?

Here is the minion file:


# clusters. #id:
# clusters. #id: dfggggg
#id:
#id: dfsfff
id:
id: rrrrpp

It is necessary that the last 4 lines change.
Here is the replacement:
sed -i "s/^\#?id:.*/id: zabbix-proxy.client.local/gm" minion

Does not work.
PS The file is in the home directory, I check it by root I checked
this regular expression in regexr.com and https://regex101.com/ it works there

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aves, 2016-03-02
@taaadm

you need to escape not a lattice, but a question mark
's/^#\?id:.*/id: zabbix-proxy.client.local/'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question