Linux FAQ : find 用法

2022/11/14閱讀時間約 2 分鐘
Linux FAQ : find 用法
find 目錄 參數 條件
參考 :
find . -type d 'xxx*'
參數
  • 目錄搜尋層數
  • maxdepth 第幾層
  • find . -maxdepth 1
  • 忽略特定目錄
  • -not -path 目錄
  • find . -name '123' -not -path './usr/*'
  • path 目錄 -prune -o
  • find . -path ./usr -prune -o -name '123'
  • -user 使用者
  • find . -user topstd -name '*' -exec ls -l {} \\;
  • 排除 使用者
  • find . ! -user topstd -name '*' -exec ls -l {} \\;
  • -szie 大小
  • find . -size +10k
  • 小於 10 k
  • find . -size -10k
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"' _ {} \\;
work b
work b
留言0
查看全部
發表第一個留言支持創作者!