Usage
find <path> <conditions> <actions>
Conditions
-name "*.c"
-type f # File
-type d # Directory
-type l # Symlink
-depth 2 # At least 3 levels deep
-regex PATTERN
-newer file.txt
-newerm file.txt # modified newer than file.txt
-newerX file.txt # [c]hange, [m]odified, [B]create
-newerXt "1 hour ago" # [t]imestamp
-path "*/node_modules" -prune # 忽略任意node_modules文件夾
Condition flow
查找當前文件夾且忽略node_modules文件夾下的,所有后綴為js的文件,-o是短路語句
find . -path "*/node_modules" -prune -o -type f -name "*.js" -print
Actions
-exec rm {} \; # 花括號代表前面find查找出來的文件名,反斜杠分號代表語句結束
-print # 打印
-delete
Examples
find . -name '*.jpg'
find . -name '*.jpg' -exec rm {} \;
find . -newerBt "24 hours ago"