【问题标题】:"Illegal option" error when using find on macOS在 macOS 上使用 find 时出现“非法选项”错误
【发布时间】:2014-11-08 13:07:24
【问题描述】:

我正在尝试仅列出末尾带有字母“R”的文件。我在macOS终端中使用find如下,

find -type f -name '*R' 

但我收到消息说illegal option --t

【问题讨论】:

    标签: macos bash shell unix find


    【解决方案1】:

    find 的第一个参数是它应该开始查找的路径。路径.表示当前目录。

    find . -type f -name '*R'
    

    您必须提供至少一个路径,但实际上您可以提供任意数量的路径:

    find ~/Documents ~/Library -type f -name '*R'
    

    【讨论】:

    • 您可能应该指定您正在谈论bsd findfind -type f -name '*R'gnu 中完全没问题。
    • 我说的是standard POSIX find
    • 是的,但是这里混淆的原因很可能是gnu find 如果您不提供参数,将默认为.。 Mac OS 默认使用bsd,如果您不向-f 提供参数,则需要一个参数。并且使用像 must provide at least one path 这样的语句而不指定 find 的版本可能只会引起更多的混乱。
    • 我遇到了这个问题,与@BroSlow 所暗示的完全一样的困惑。
    猜你喜欢
    • 1970-01-01
    • 2021-01-27
    • 2019-12-29
    • 1970-01-01
    • 2020-04-19
    • 1970-01-01
    • 2014-07-12
    • 2018-05-17
    • 2021-02-17
    相关资源
    最近更新 更多