Reputation: 2085
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
Reputation: 4423
Probably something like this:
find folder -name "*.[rR]" -exec sed -i '/pattern/d' {} \;
Upvotes: 1