N
N
Ninazu2020-01-12 14:00:30
linux
Ninazu, 2020-01-12 14:00:30

How to write a sed-friendly regex to replace Directory in hosts configuration?

Actually the task is to replace the directory in the configuration file with another one.
The regex seems to find what it needs
https://regex101.com/r/ryEH50/8/
But I don't know how to adapt it so that sed works. I assume that this is due to line
breaks Tried something like this

NEW_DIR="/var/www/debug.loc"
sed -i -E "s/(<VirtualHost\s\*:9007>[\s\S]*?[^#]\s<Directory\s)[\/._a-z]+(>[\s\S]*?<\/VirtualHost>)/\1{$NEW_DIR}\2/" /etc/apache2/size-available/000-default.conf

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question