sed

Unix replace string in file

A string can be replaced within a unix file using the 'sed' command. For example, it may that you've created a MySQL dump and you want to update a string and then import it back into the database.

For example, let's say we have a string '/var/www/vhosts/intranet2' within a file named 'intranet.sql' and we want to replace it with '/var/www/vhosts/intranet' and save it into a new file named 'intranet-updated.sql'.

You simply need to enter: