為了按名稱查找檔案,我有這個命令:
find . /home/XYZ/ -name '*abc*'
但它會在目錄 XYZ 及其子目錄中顯示結果。我只需要在特定檔案夾“XYZ”中搜索,而不是在子目錄中搜索。
我怎樣才能做到這一點?
uj5u.com熱心網友回復:
find . XYZ/ -maxdepth 1 -name *abc*
輸出
find . XYZ/ -maxdepth 1 -name *abc*
XYZ/abc.txt
find . XYZ/ -name *abc*
./XYZ/abc.txt
./XYZ/tuv/123abc
XYZ/abc.txt
XYZ/tuv/123abc
man find
-maxdepth levels
Descend at most levels (a non-negative integer) levels of directories below the starting-points. Using
-maxdepth 0 means only apply the tests and actions to the starting-points themselves.
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/517848.html
標籤:Unix寻找
上一篇:bash中的三元運算或默認值
