curious
curious

Reputation: 1554

Find and sed: how to replace files in place?

I want to replace a phrase composed of two words separated with a space with another two words:

find . -type f -exec sed 's/w1 w2/w3 w4/g' {} +

However, even if the pattern 'w1 w2' occurs in many files on the current dir, nothing seems to change.

Upvotes: 0

Views: 169

Answers (1)

jdigital
jdigital

Reputation: 12296

Try specifying the -i or --in-place option for sed. Otherwise it won't actually change the file. Check the sed documentation for more info.

Side note: you'll find it easier to troubleshoot if you first get this working without find. Start small, then build up.

Upvotes: 1

Related Questions