Answer the question
In order to leave comments, you need to log in
[SOLVED] Linux sed regular expression splitting
Hello Habrazhitel!
Previously, sed always correctly processed multiple regular expressions separated by semicolon ";". This allowed us to run sed only once to process multiple regular expressions.
For example, comment on the lines containing "bugcode" and "betacode"
sed -i '/bugcode/s/^/\#/; /betacode/s/^/\#/' /etc/file
But today I found that this does not always work.
For example, you need to add the line "Ivan" after the line containing "123" and add the line "John" after the line containing "456".
sed -i '/123/a Ivan; /456/a John' /etc/file
As a result, the second regular expression is ignored and inserted as text.
Separately, regular expressions work correctly.
Please tell me where to dig, Google did not help.
Thank you in advance
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question