Hello,
I want to do a simple substitution using sed but I can't find a solution. Basically, from a Apache conf file, I would like to remove everything included between the <VirtualHost> and </VirtualHost> e.g
SSLMutex file:/var/run/ssl_mutex
<VirtualHost _default_:443>
# A lot of config that I don't want
<VirtualHost>
#another config
So the result I want is everything withtout the VirtualHost part:
SSLMutex file:/var/run/ssl_mutex
#another config
I tried:
gsed -e "s#<VirtualHost.*</VirtualHost>##g" /tmp/test
but it does not match the line block
Any ideas ?
R.
sed '/<VirtualHost/d' input_file
Try with awk...
awk '/<VirtualHost/,/VirtualHost>/{next}1' infile
Or sed...
sed '/<VirtualHost/,/VirtualHost>/d' infile
try this
sed -e 's/\<Virtualhost[^$]+\<\/VirtualHost\>//g' /tmp/test
ok ! Thanks for the fast answer.
only this code doesnt work..
let try this like
sed -e '/<VirtualHost/d' -e '/^\# A/d' myfile
this code doesnt work..
+ isnt unnecessary..this character doesnt merge multilines in sed..
for multi line edit use N
or with + use extended regular expression with r
sed -r '/<VirtualHost._+/d' test | sed -r '/<VirtualHost>.?/d' | sed -e '/# A/d'
SSLMutex file:/var/run/ssl_mutex
#another config
Posix basic regular expression syntax without -r option (instead of use extended regular expressions)
sed -e '/<VirtualHost.\+/d' -e '/<VirtualHost>\?/d' test | sed -e '/# A/d'
SSLMutex file:/var/run/ssl_mutex
#another config
Regards
ygemici