removing a block of text with sed
I've got a script that creates multiple instances of a web-application, each with it's own url (e.g host.com/app1, host.com/app2).
What I do now, is create a separate "site" file for apache2 and then enable it (a2ensite under ubuntu). This works, but I eventually end up with a bunch of files in /etc/apache2/sites-available which is ugly. So the concept is to have a single file for all of the projects with corresponding sections of it being added (no prob) and removed as a web-app gets removed. Could anyone please share experience on how to make sed search for the pattern like Code:
<-- web_app_name --> Is it possible with sed at all? (can't imagine the way this could get done) TIA |
Hi,
This deletes in-place, try without the -i option first: sed -i '/<-- web_app_name -->/,/<-- web_app_name -->/d' infile Hope this helps. |
if you have Python, here's an alternative:
sample input: Code:
<-- web_app_name --> Code:
data = open("file").readlines() Code:
#./test.py |
druuna, thanks. this worked out perfectly.
ghostdog74, thanks. Python is what's I'm going to start learning really soon. |
All times are GMT -5. The time now is 01:47 AM. |