Reputation: 133
I have many .sql
files in subfolders. I am presently manually opening them up, and searching for OLDSERVERNAME
, and replacing it with NEWSERVERNAME
(I'm doing migration). There must be a faster way to do this. I tried using FART, but I guess I wasn't doing it right.
This is what I tried(in main folder):
fart -i -p -c *.sql OLDSERVERNAME NEWSERVERNAME
Can I perhaps use unix utilities for this purpose?
Upvotes: 8
Views: 11441
Reputation: 21
On MacOS - I had to add a backup file extension
sed -i '.bak''s/OLDSERVERNAME/NEWSERVERNAME/g' *.sql
Upvotes: 2
Reputation: 77105
You can use sed
for this. sed
stands for S tream Ed itor
sed -i 's/OLDSERVERNAME/NEWSERVERNAME/g' *.sql
.sql
extension. Look up sed
man page for more details.
Upvotes: 14