I am writing a bash script for installing django with postgresql database automatically.
Now , I want to replace database name by command ,since it is using sqlite3 database file path.
I wrote this command:
sudo sed -i 's/os.path.join(BASE_DIR, 'db.sqlite3'),/'$project_name',/g' $projects_name/settings.py
But this is not changed while I am making the django project.
How to change this , please help me.
Answer
Use double-quotes around sed
for variable expansion & to preserve single quotes.
sed -i "s/os.path.join(BASE_DIR, 'db.sqlite3'),/$project_name,/g" "$project_name/settings.py"
tested working fine on GNU sed version 4.2.1
No comments:
Post a Comment