笔记(find)

mac2024-10-04  62

find语法 find 目录 选项 动作

根据文件类型查找-type f 普通文件 file d 目录 directory l 链接文件 b 块设备文件 c 字符设备文件 p 管道文件 find /tmp/jsetc -type f find /tmp/jsetc -type l

find反向查找 find /tmp/jsetc/ -type f ! -user nobody

linux文件时间,可用stat查看 atime #access time访问时间 mtime #modify time修改时间,比较常用。内容修改更新这个时间 ctime #change time,包含内容修改或者属性修改(文件属主、文件权限)

atime不生效原因 由于atime频繁更改会对文件io产生影响,因此很多线上系统atime的修改是禁止的。挂载的时候使用noatime

根据修改时间查找 find /tmp/jsetc -type f -mmin +3 #3分钟前修改 find /tmp/jsetc -type f -mtime +6 #6天前修改的 find /tmp/jsetc/ -type f -newer file_6 #相对文件时间查找 find /tmp/jsetc/ -type f -newermt ‘2018-11-25 13:15:00’ #绝对时间查找

find结合xargs find /tmp/jsetc/ -type f -newer file_6 -print | xargs rm find /tmp/jsetc/ -type f -print0|xargs -0 grep ‘jsetc’

find结合xargs存在问题 touch ‘/tmp/jsetc/blank jsetc’ find /tmp/jsetc -type f -name “blank*”

echo -e 换行 处理特殊字符 ls -R 用递归方式列出文件 stdin 输入 stdout 输出 strerr 输出标准错误 2>/dev/null:意思就是把错误输出到“黑洞” grep -v ‘^$’ :命令的作用是过滤空白符

最新回复(0)