Hi,
I am a newbie to shell scripting and to Linux environment as well.
In my project I am trying to search for following text from the httpd.conf file
<Directory '/somedir/someinnerdir'>
AllowOverride All
</Directory>
and then remove this text and again rewrite the same text. The reason to do this rewriting is that the script will be run on first installation of the web app, but it may again be run some time later as other part of this shell script is performing other tasks as well. So for first time this text wont be found and will simply be written but later again when script is run this text will be found and will need to be removed and the written again.
So the part of my script with which I am trying to achieve this is something like :
grep -ve "<Directory '/somedir/someinnerdir'>\\nAllowOverride All\\n</Directory>" /etc/httpd/conf/httpd.conf > tmp_direct
echo -e "<Directory '/somedir/someinnerdir'>\\nAllowOverride All\\n</Directory>" >> tmp_direct
mv tmp_direct /etc/httpd/conf/httpd.conf
I dont have the code in front of me currently so there may be some syntactical errors above but the logic/coding is same.
Above code fragment is not able to do what I want to achieve as the grep command doesnt support multiline searching.
My OS is Fedora 8.
Can you please suggest something in this code to achieve what is needed or may be some other alternative.
Any help in this regard will be highly appreciated.
Thanks in advance.