Princy
Princy

Reputation: 633

Find replace text in multiple files in subdirectories. Exclude some subdirectories

I want to find replace a patter1 into pattern2 only in certain files of my subdirectories. But exclude some subdirectories with replacement. What is wrong with this command?

find ./ -type f --exclude-dir='workspace' --exclude-dir='builds' \
    -exec sed -i '' 's/foo/bar/g' {} \;

Upvotes: 0

Views: 156

Answers (1)

choroba
choroba

Reputation: 241858

I don't see the option --exclude-dir in man find (I do in man grep, but you can't just borrow other command's options).

Try

find . -type f -not -path './workspace*' ...

Upvotes: 2

Related Questions