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
精彩评论