在子目录中的多个文件中查找替换文本。排除一些子目录
Find replace text in multiple files in subdirectories. Exclude some subdirectories
我只想在我的子目录的某些文件中找到将 patter1 替换为 pattern2 的方法。但是用替换排除一些子目录。这个命令有什么问题?
find ./ -type f --exclude-dir='workspace' --exclude-dir='builds' \
-exec sed -i '' 's/foo/bar/g' {} \;
我在 man find
中没有看到选项 --exclude-dir
(我在 man grep
中看到了,但你不能只借用其他命令的选项)。
尝试
find . -type f -not -path './workspace*' ...
我只想在我的子目录的某些文件中找到将 patter1 替换为 pattern2 的方法。但是用替换排除一些子目录。这个命令有什么问题?
find ./ -type f --exclude-dir='workspace' --exclude-dir='builds' \
-exec sed -i '' 's/foo/bar/g' {} \;
我在 man find
中没有看到选项 --exclude-dir
(我在 man grep
中看到了,但你不能只借用其他命令的选项)。
尝试
find . -type f -not -path './workspace*' ...