https://medium.com/@berrybearw/linux-faq-find-用法-a176c5e63001
find 目錄 參數 條件
介紹 : 找尋檔案或目錄在哪裡
格式 find 目錄 參數 條件
常用 找尋當下目錄檔案
find (找尋) . (當下所在目錄) -name (檔案名稱為) 123find . -name '123'
模糊搜尋請搭配 正規表達式
找尋當下目錄結尾是 123 檔案find . -name '*123'
參考 :
https://blog.gtwang.org/linux/unix-linux-find-command-examples/
https://stackoverflow.com/questions/4210042/how-do-i-exclude-a-directory-when-using-find
find . -type d 'xxx*'
參數
find . -name '123' -not -path './usr/*'
find . -path ./usr -prune -o -name '123'
find . -user topstd -name '*' -exec ls -l {} \;
find . ! -user topstd -name '*' -exec ls -l {} \;
find . -size +10k
find . -size -10k
https://stackoverflow.com/questions/38843212/how-to-use-echo-with-find-in-bash
The shell redirection, >>
is being done at first, a file named {}
is being created before even the find
starts and the strings (the number of files are in there) are being written to the file {}
.
You need:
find . -type f -exec bash -c 'echo "This file found" >>"$1"' _ {} \;