Taylor
Taylor

Reputation: 2085

command line utility that can search recursively for files with a certain suffix, and remove all lines in all files with a certain pattern?

How do I use sed (or any other command line utility) to search recursively for all .r and .R files, and remove all lines in all files with a certain pattern?

I've seen this command

sed -i '/"pattern"/d' folder/*

But this works on all the files in folder/, which might miss some stuff, and harm other files I don't want to touch. My directory has a tree-like pattern, and so I need to search everything recursively.

Upvotes: 0

Views: 43

Answers (1)

kofemann
kofemann

Reputation: 4423

Probably something like this:

find folder -name "*.[rR]" -exec sed -i '/pattern/d' {} \;

Upvotes: 1

Related Questions