"发现:路径必须precede前pression:"如何指定递归搜索也发现在当前目录下的文件? [英] "find: paths must precede expression:" How do I specify a recursive search that also finds files in the current directory?

查看:168
本文介绍了"发现:路径必须precede前pression:"如何指定递归搜索也发现在当前目录下的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很难得到的找到寻找当前目录及其子目录下的匹配,以及。

I am having a hard time getting find to look for matches in the current directory as well as its subdirectories.

当我运行找* test.c以,只给了我在当前目录中匹配。 (不看子目录中)

When I run find *test.c it only gives me the matches in the current directory. (does not look in subdirectories)

如果我尝试找到。 -name * test.c以我希望同样的结果,而是它给我只能说是在一个子目录匹配。当有应匹配在工作目录中的文件,它给我:找到:路径必须precede前pression:mytest.c

If I try find . -name *test.c I would expect the same results, but instead it gives me only matches that are in a subdirectory. When there are files that should match in the working directory, it gives me: find: paths must precede expression: mytest.c

这是什么意思的错误,我怎么能得到比赛无论从当前目录及其子目录?

What does this error mean, and how can I get the matches from both the current directory and its subdirectories?

推荐答案

尝试把它放在引号 - 你正在运行到shell的通配符扩展,还等什么你真的遇到过找的样子:

Try putting it in quotes -- you're running into the shell's wildcard expansion, so what you're acually passing to find will look like:

find . -name bobtest.c cattest.c snowtest.c

...导致语法错误。因此,尝试这个:

...causing the syntax error. So try this instead:

find . -name '*test.c'

请注意周围的文件前pression单引号 - 这些将停止外壳(bash)的扩展您的通配符

Note the single quotes around your file expression -- these will stop the shell (bash) expanding your wildcards.

这篇关于"发现:路径必须precede前pression:"如何指定递归搜索也发现在当前目录下的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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