【问题标题】:How to write command find with variable in terminal如何在终端中使用变量编写命令查找
【发布时间】:2014-12-15 08:57:12
【问题描述】:

我想从如下变量运行 find 命令:

$myFind = "/Volumes/WORKSPACE/MyProject/ -name '*.html' ! -name 'MyFile.html'"

$find $myFind

但它似乎不起作用。如何使用变量执行查找?

请帮忙。

【问题讨论】:

    标签: variables terminal find command


    【解决方案1】:

    删除“=”前后的空格。

    我试过了,效果很好。如果仍有错误,请告诉我。

    代码:

    myFind="/Volumes/WORKSPACE/MyProject/ -name *.html ! -name MyFile.html"
    find $myFind
    

    【讨论】:

    • 如果您的工作目录不包含任何 .html 文件,这可能在这里工作,但否则应该失败(因为 * 将像文字 * 字符,如果没有 html 文件工作目录)。使用数组可以解决问题。请参阅this 了解更多信息。
    猜你喜欢
    • 2019-03-21
    • 2019-05-10
    • 1970-01-01
    • 2020-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-31
    相关资源
    最近更新 更多