开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜