这个是对的:
$ find . -name *main.o
./main.o
Run Code Online (Sandbox Code Playgroud)
那么,为什么我找不到*.o?
$ find . -name *.o
find: paths must precede expression: main.o
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
Run Code Online (Sandbox Code Playgroud) find . -name *.rb
Run Code Online (Sandbox Code Playgroud)
不适用于我的 ubuntu
我要做
find . -name "*.rb"
Run Code Online (Sandbox Code Playgroud)
让它工作。
这是为什么?
我学会了如何在 find 命令中使用通配符,但今天我看到了一个奇怪的行为。
当我在搜索位置以外的任何地方时,我不需要单引号或双引号进行通配
$ pwd
/home
$ find / -name *c
...
it is ok
Run Code Online (Sandbox Code Playgroud)
但
$ pwd
/
$ find / -name *c
find: paths must precede expression: proc
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
Run Code Online (Sandbox Code Playgroud)
发生什么事?