【发布时间】:2016-02-23 06:10:32
【问题描述】:
我只想在我的子目录的某些文件中找到将模式 1 替换为模式 2。但排除一些替换的子目录。这个命令有什么问题?
find ./ -type f --exclude-dir='workspace' --exclude-dir='builds' \
-exec sed -i '' 's/foo/bar/g' {} \;
【问题讨论】:
我只想在我的子目录的某些文件中找到将模式 1 替换为模式 2。但排除一些替换的子目录。这个命令有什么问题?
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*' ...
【讨论】:
-f 而不仅仅是f。