AWK find and replace URL
I'm creating a bash script that will allow for me to move my database between dev, stage and prod servers. I already have a script that backs up the database to a compressed file, which is what I am using for the find and replace. My only problem is that I can't figure out how to escape the url I am searching for.
Code:
strFrom="dev\.domain\.com" Code:
awk: s/dev\.domain\.com/stage\.domain\.com/g Thanks! |
You need to use sed instead of using awk for the format you mentioned
Use Code:
sed 's/'"$strFrom"'/'"$strTo"'/g' |
Hi,
The mixing of quotes isn't needed: sed "s/$strFrom/$strTo/" You also do not need to escape the dots in the replacement string (strTo="stage.domain.com"). Hope this helps. |
Thanks!
Just wanted to say thanks for the help! The following code works like a charm.
Code:
strFrom="dev.domain.com" |
Hi,
Quote:
I hope you meant: sed "s/$strFrom/$strTo/g" |
Quote:
check the file size Code:
gunzip /srv/admin/database-......sql.gz |
All times are GMT -5. The time now is 04:29 AM. |