开发者

Replace text from a MySQL dump using cat (or something else) in shell

开发者 https://www.devze.com 2022-12-27 07:02 出处:网络
I\'ve got a database dump in MySQL where I want to replace ocurrencies of paths that are in the dump as plaintext.

I've got a database dump in MySQL where I want to replace ocurrencies of paths that are in the dump as plaintext.

In this开发者_运维百科 particular case I'd like to replace:

/var/www/

for

/home/www/

How could I safely do that using cat or any other shell tool?


cat old.file | sed 's%/var/www/%/home/www/%g' > new.file


Try:

sed 's/\/var\/www\//\/home\/www\//' old_file > new_file


awk '{gsub("/var/www/","/home/www/")}1' mydump >temp && mv temp mydump
0

精彩评论

暂无评论...
验证码 换一张
取 消