I have a file with this content
import os
import sys
sys.path.append('/home/user/dj/project/')
sys.path.append('/home/user/dj/')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
/home/user/dj/proj/ and /home/user/dj/ could be other, unknown values.
I have a bash script to do an installation, and in there I want to execute something to change those lines to this
import os
import sys
sys.path.append('/var/django/proj/')
sys.path.append('/var/django/')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
I tried with sed but I had troubles with greediness in regex.
I tried with perl -pi -e s/str1/str2/ but I had troubles because perl repaces all occurences.
EDIT:
To clarify, I want to replace only the values inside the single quotes. i.e:
sys.path.append('foo') with sys.path.append('what I want') and
sys.path.append('bar') with sys.path.append('the second thing I want')
and bar could be different or equal to foo
I finally used this
with that carriage return before the
}is the only thing that worked for me.