![路径必须位于表达式之前](https://linux22.com/image/1021771/%E8%B7%AF%E5%BE%84%E5%BF%85%E9%A1%BB%E4%BD%8D%E4%BA%8E%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%B9%8B%E5%89%8D.png)
虽然有以 结尾的文件txt
,但我无法使用find
命令来搜索它们。
$ ls *.txt
backprop.txt
bfs.txt
streamcluster.txt
$ find . -name *.txt
find: paths must precede expression: `bfs.txt'
find: possible unquoted pattern after predicate `-name'?
$ find . -name txt
$
我该如何修复它?
答案1
来自find
手动的:
2.2.1 基本名称模式
测试:-name pattern
测试:-iname pattern
[...]
请注意,通配符必须用引号引起来以防止其被壳膨胀。
[...]
因此命令应该是:
find . -name "*.txt"