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"