On Sun, Feb 28, 2010 at 4:41 PM, Stroller
<strol...@stellar.eclipse.co.uk> wrote:
>
> On 28 Feb 2010, at 19:06, Etaoin Shrdlu wrote:
>>
>> On Sunday 28 February 2010, Stroller wrote:
>>>
>>> ...
>>>  $ sed 's/Project Gutenberg/Wordsworth Classics/' foo > bar
>>>  $ mv bar foo
>>>  $
>>
>> Have a look at sed's "-i" option.
>>
>>> Using `grep` I can search *recursively* through directories to find the
>>> text I'm looking for. EG: `grep -R Gutenberg ~`
>>>
>>> I would like to find every instance of $foo in a directory hierarchy and
>>> replace it with $bar.
>>>
>>> ...
>>
>> 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. ;)

Why are you concerned about a backup? It is always good to do backups
before changing things. You never know when something might go wrong.
;)

Reply via email to