代码之家  ›  专栏  ›  技术社区  ›  yagev

在csh脚本文件中使用“find”

  •  0
  • yagev  · 技术社区  · 9 年前

    我在UNIX中运行一个.csh文件,其中包含以下脚本

    #!/bin/tcsh -f
    set path = "$1"
    find "$path" -name myfolder
    

    并得到以下消息

    find: Command not found.
    

    我错过了什么?

    谢谢

    1 回复  |  直到 9 年前
        1
  •  2
  •   ghoti    9 年前

    这个 $path 变量是特殊的-它告诉shell在哪里可以找到像这样的工具 find .:-)使用不同的变量名。

    从交互式shell中,您可以看到 $路径 通常通过回音看起来像。下面是我在FreeBSD服务器上的路径:

    ghoti% echo $path
    /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /home/ghoti/bin /usr/X11R6/bin /usr/games
    

    如果此列表被替换为其他内容,例如 $1 ,那么tcsh就不知道该进去看看了 /usr/bin 找到 发现 :

    ghoti% which find
    /usr/bin/find
    ghoti% set path = "hello world"
    ghoti% which find
    find: Command not found.
    ghoti%