On Sunday 28 February 2010, Stroller wrote:

> > A starting point could be (after you make a backup of the whole tree)
> >
> > find /basedir -type f -exec sed -i 's/foo/bar/g' {} +
> 
> Many thanks - that looks great!
> 
> My only concern is that it is unreliable enough that you state the
> need to backup first. ;)

The problem is that with such a command it's very easy to screw up hundreds or 
thousands of files (depending how many you have in the directory tree) in a 
non-reversible way, for example due to a slight error in the sed command.

Hence the suggestion of backing up before trying. Alternatively, you can 
supply an extension to the -i option, as in -i.bak for example, to have sed 
create backup copies of the changed files (which you can then remove when 
you've made sure the changes have been successful).

Reply via email to