Linux shell bulk edit using SED editor

Posted by Jiltin     17 December, 2008    910 views   

Question:

I generally use Perl for this
ex.

perl -e ’s/pattern/replace/g’ -p -i <filename>

I did something like this..

find . -type f -exec perl -e ’s/pattern/replace/g’ -p -i {} \;

I want to do this with “sed”

but what I get is the output being printed on the screen..

I can do

sed -e ’s/pattern/replace/g’ < input > output

but in my case of “find”, i dont want to create a bunch of output files, rather the editing to take place in the same file..

Any ideas?

Answer

grep -il pattern *‘ xargs sed -i ‘s/pattern/replace/g

Have your comment, if this is helping you.

Following Google Searches Lead To This Post:
sed bulk edit files

Post to Twitter  Post to Delicious  Post to Digg    Post to StumbleUpon

Categories : Scripts Unix Tags : , ,

Comments

No comments yet.


Leave a comment

(required)

(required)