1 |
On 28 Feb 2010, at 19:06, Etaoin Shrdlu wrote: |
2 |
> On Sunday 28 February 2010, Stroller wrote: |
3 |
>> ... |
4 |
>> $ sed 's/Project Gutenberg/Wordsworth Classics/' foo > bar |
5 |
>> $ mv bar foo |
6 |
>> $ |
7 |
> |
8 |
> Have a look at sed's "-i" option. |
9 |
> |
10 |
>> Using `grep` I can search *recursively* through directories to find |
11 |
>> the |
12 |
>> text I'm looking for. EG: `grep -R Gutenberg ~` |
13 |
>> |
14 |
>> I would like to find every instance of $foo in a directory |
15 |
>> hierarchy and |
16 |
>> replace it with $bar. |
17 |
>> |
18 |
>> ... |
19 |
> A starting point could be (after you make a backup of the whole tree) |
20 |
> |
21 |
> find /basedir -type f -exec sed -i 's/foo/bar/g' {} + |
22 |
|
23 |
Many thanks - that looks great! |
24 |
|
25 |
My only concern is that it is unreliable enough that you state the |
26 |
need to backup first. ;) |
27 |
|
28 |
Stroller. |