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但不是不可見的字符和字符。 –