为什么不找** **发现了什么? [英] Why doesn't **find** find anything?

查看:144
本文介绍了为什么不找** **发现了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要找的shell脚本安装在我的系统上的文件,但发现不起作用:

I'm looking for shell scripts files installed on my system, but find doesn't work:

$ find /usr -name *.sh

不过,我知道有一吨的脚本在那里。例如:

But I know there are a ton of scripts out there. For instance:

$ ls /usr/local/lib/*.sh
/usr/local/lib/tclConfig.sh  
/usr/local/lib/tkConfig.sh

为什么不发现工作

推荐答案

尝试引用通配符:

$ find /usr -name \*.sh

$ find /usr -name '*.sh'

如果你碰巧有一个匹配的文件*。SH 在当前工作目录,通配符会发现看到它之前扩大。如果你碰巧有一个在你的工作目录中名为tkConfig.sh文件,在找到命令将扩展为:

If you happen to have a file that matches *.sh in the current working directory, the wildcard will be expanded before find sees it. If you happen to have a file named tkConfig.sh in your working directory, the find command would expand to:

$ find /usr -name tkConfig.sh

这将只找到名为tkConfig.sh文件。如果你有一个匹配多个文件的 * SH 后,你会得到从语法错误的找到

which would only find files named tkConfig.sh. If you had more than one file that matches *.sh, you'd get a syntax error from find:

$ cd /usr/local/lib
$ find /usr -name *.sh
find: bad option tkConfig.sh
find: path-list predicate-list

再次原因是通配符扩展为两个文件:

Again, the reason is that the wildcard expands to both files:

$ find /usr -name tclConfig.sh tkConfig.sh

引述通配符prevents它被prematurely扩大。

Quoting the wildcard prevents it from being prematurely expanded.

另一种可能是的/ usr或它的一个子目录是符号链接。 发现通常不会跟随链接,所以你可能需要在 -follow 选项:

Another possibility is that /usr or one of its subdirectories is a symlink. find doesn't normally follow links, so you might need the -follow option:

$ find /usr -follow -name '*.sh'

这篇关于为什么不找** **发现了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆