【问题标题】:How can I simplify this find command that has too many -o's?如何简化这个包含太多 -o 的 find 命令?
【发布时间】:2020-04-02 11:30:32
【问题描述】:
find . "$HOME"/Documents -iname *.md -o -iname *.html -o -iname *.css -o -iname *.js -o -iname *.ts -o -iname *.txt

我找不到一种方法来摆脱所有这些糟糕的-o -iname 并拥有类似*.{md,html} 的东西。它必须是一个语句。

奖金回合问题...如何从搜索中排除 node_modules :)?

【问题讨论】:

  • 额外问题:-path node_modules -prune

标签: regex linux shell


【解决方案1】:

使用允许交替的-iregex 选项:

find "$HOME"/Documents -regextype awk -iregex '.*\.(md|html|css|js|ts|txt)'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多