NON-BUGS
Operator precedence surprises
The command find . -name afile -o -name bfile -print will never print
afile because this is actually equivalent to find . -name afile -o \(
-name bfile -a -print \). Remember that the precedence of -a is
higher than that of -o and when there is no operator specified
between tests, -a is assumed.
“paths must precede expression” error message
$ find . -name *.c -print
find: paths must precede expression
Usage: find [-H] [-L] [-P] [-Olevel] [-D ... [path...] [expression]
This happens because *.c has been expanded by the shell resulting in
find actually receiving a command line like this:
find . -name frcode.c locate.c word_io.c -print
That command is of course not going to work. Instead of doing things
this way, you should enclose the pattern in quotes or escape the
wildcard:
$ find . -name '*.c' -print
$ find . -name \*.c -print
4 回答
试着把它放在引号中:
从查找手册:
试着把它放在引号中 - 你正在进入shell的通配符扩展,所以你正在寻找的东西看起来像:
...导致语法错误 . 所以试试这个:
请注意文件表达式周围的单引号 - 这将停止shell(bash)扩展通配符 .
发生的事情是shell正在将“* test.c”扩展为文件列表 . 尝试将星号转义为: