linux基础_find命令

蛋蛋 2024年03月20日 48 0

常用命令

清理15天前的文件

find /path/to/directory -type f -mtime +15 -exec rm {} \;

find获取文件名匹配a.log或b.log的文件

find /path/to/directory -type f \( -name "a.log" -o -name "b.log" \)

注:括号 ( 和 ) 是用来对表达式进行分组的,以确保逻辑的正确性。因为在命令行中,括号通常被用作特殊字符(用于命令组合、子shell等),为了在 find 命令中正确解释括号作为表达式的一部分,需要使用反斜杠进行转义。这样可以确保括号被正确传递给 find 命令进行处理。

查找并清理时间点生成的文件

find . -type f -not -newermt "2024-03-07 09:35:00" -name "aaa.log*"  -exec rm {} \;

查找并清理时间点生成的文件

find . -type f -newermt "2024-03-07 09:35:00" -name "aaa.log*"  -exec rm {} \;

find/findstr[win]

Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions:

operators (decreasing precedence; -and is implicit where no others are given):
      ( EXPR )   ! EXPR   -not EXPR   EXPR1 -a EXPR2   EXPR1 -and EXPR2
      EXPR1 -o EXPR2   EXPR1 -or EXPR2   EXPR1 , EXPR2

positional options (always true): -daystart -follow -regextype

normal options (always true, specified before other expressions):
      -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
      --version -xautofs -xdev -ignore_readdir_race -noignore_readdir_race

tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
      -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
      -ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
      -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
      -nouser -nogroup -path PATTERN -perm [-/]MODE -regex PATTERN
      -readable -writable -executable
      -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
      -used N -user NAME -xtype [bcdpfls]
      -context CONTEXT


actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print 
      -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit
      -exec COMMAND ; -exec COMMAND {} + -ok COMMAND ;
      -execdir COMMAND ; -execdir COMMAND {} + -okdir COMMAND ;

Report (and track progress on fixing) bugs via the findutils bug-reporting
page at http://savannah.gnu.org/ or, if you have no web access, by sending
email to <bug-findutils@gnu.org>.
Last Updated: 2024/03/20 15:12:25
linux基础_操作系统官网 [Docker] /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_ABI_DT_RELR' not found (required by docker)