【问题标题】:Find replace text in multiple files in subdirectories. Exclude some subdirectories在子目录中的多个文件中查找替换文本。排除一些子目录
【发布时间】:2016-02-23 06:10:32
【问题描述】:

我只想在我的子目录的某些文件中找到将模式 1 替换为模式 2。但排除一些替换的子目录。这个命令有什么问题?

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

【问题讨论】:

    标签: unix replace sed find


    【解决方案1】:

    我在man find 中没有看到选项--exclude-dir(我在man grep 中看到了,但你不能只借用其他命令的选项)。

    试试

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

    【讨论】:

    • 出了问题可能是复制了您的拼写错误-f 而不仅仅是f
    猜你喜欢
    • 2012-02-13
    • 1970-01-01
    • 2015-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-12
    • 2011-10-09
    相关资源
    最近更新 更多