首页 > 系统服务 > 详细

linux find 命令

时间:2020-04-18 11:45:20      阅读:53      评论:0      收藏:0      [点我收藏+]

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"

linux find 命令

原文:https://www.cnblogs.com/everlose/p/12724837.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!