查找文件
find /backup -type f -regex ".*\(\.tar.gz\|\.log\)" -mtime -7
-iregex 不区分大小写
find /backup/ -type f -mtime -7 \( -name "*.log" -o -name "*.tar.gz" \)
-iname 不区分大小写
找到文件夹中所有文件
[root@nfs01 /server/scripts]# find /backup/ -type f -iregex ".+"
/backup/exports
/backup/172.16.1.31/backup_2018-03-10-6.tar.gz
/backup/172.16.1.31/backup_2018-03-08.tar.gz
/backup/172.16.1.31/backup_2018-03-09.tar.gz
/backup/172.16.1.31/flag_2018-03-10-6.log
/backup/172.16.1.31/flag_2018-03-09.log
/backup/172.16.1.31/flag_2018-03-08.log
/backup/1.tt.gz
/backup/2.tardgz
/backup/etc.tar.gz
/backup/exports.TAR.GZ
找到文件夹中指定文件,取反显示
[root@nfs01 /server/scripts]# find /backup/ -regextype "posix-egrep" -type f ! -iregex ".+[a-z]{4,6}_[0-9]{4}-[0-9]{2}-[0-9]{2}(\.tar\.gz|\.log)"
/backup/exports
/backup/172.16.1.31/backup_2018-03-10-6.tar.gz
/backup/172.16.1.31/flag_2018-03-10-6.log
/backup/1.tt.gz
/backup/2.tardgz
/backup/etc.tar.gz
/backup/exports.TAR.GZ
找到文件夹中指定文件
[root@nfs01 /server/scripts]# find /backup/ -regextype "posix-egrep" -type f -iregex ".+[a-z]{4,6}_[0-9]{4}-[0-9]{2}-[0-9]{2}(\.tar\.gz|\.log)"
/backup/172.16.1.31/backup_2018-03-08.tar.gz
/backup/172.16.1.31/backup_2018-03-09.tar.gz
/backup/172.16.1.31/flag_2018-03-09.log
/backup/172.16.1.31/flag_2018-03-08.log