Linux file content replacement issue

0

1

I am using Linux Red Hat 5 Enterprise version.

For all files in the current directory, I want to replace all occurrences of /foo/goo/zoo (which are contained in file contents) to /a/b/c.

Any ideas how I can implement that quickly?

George2

Posted 2010-07-28T12:52:40.490

Reputation: 4 239

Answers

3

sed -i 's!/foo/goo/zoo!/a/b/c!g' *

Ignacio Vazquez-Abrams

Posted 2010-07-28T12:52:40.490

Reputation: 100 516

1

find DIR -type -f -exec sed -i 's!/foo/goo/zoo!/a/b/c!g' '{}' ';'

(the solution of ignacio is correct, but the glob operator * might run out of space when facing lots of files).

akira

Posted 2010-07-28T12:52:40.490

Reputation: 52 754