3
我想知道的是什么这两个命令的区别..找不到。 -name * .txt并找到。 -name“* .TXT”
find . –name *.txt
find . –name "*.txt"
我在系统中运行它,并不能找到任何区别, 是什么符号" "
吗?
我想知道的是什么这两个命令的区别..找不到。 -name * .txt并找到。 -name“* .TXT”
find . –name *.txt
find . –name "*.txt"
我在系统中运行它,并不能找到任何区别, 是什么符号" "
吗?
当你不使用周围的glob模式,即报价时,你说:
find . -name *.txt
然后外壳将通过这些作为参数之前扩大*.txt
到匹配的文件中当前目录到find
。如果找不到与该模式匹配的文件,则行为与引用的变体类似。
当您使用引号,即当你说:
find . -name "*.txt"
外壳经过*.txt
作为参数传递给find
。
指定glob时总是使用引号(特别是当用作参数find
时)。
一个例子可能帮助:
$ touch {1..5}.txt # Create a few .txt files
$ ls
1.txt 2.txt 3.txt 4.txt 5.txt
$ find . -name *.txt # find *.txt files
find: paths must precede expression: 2.txt
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
$ find . -name "*.txt" # find "*.txt" files
./2.txt
./4.txt
./3.txt
./5.txt
./1.txt
旁白:看起来你已经使用了一个字处理器准备了这个问题。切勿使用文字处理器编辑代码,除非您喜欢寻找看起来像ASCII但不是不可见的字符和字符。 –