Shell Script (ii)
#find查找文件 to find based on time, name, UID, GID, permissions, size, etc.
A file or directory accessed within #-amin-10:10 minutes; a file or directory accessed +10:10 minutes ago. The time unit is minutes.
#查找10分钟之前30分钟之内访问过的文件或目录
Find/home-amin +10-a-amin-30
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/14/wKiom1Vyu6WAijEmAAEuwlLInbU403.jpg "/>
Files or directories accessed within #-atime-2:48 hours, or files or directories accessed +2:48 hours ago.
#时间单位为24小时, i.e. 2*24=48 hours.
#查找1天之前3天之内访问过的文件或目录
find/var/log/-atime +1-a-atime-30-exec ls-l {} \;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/10/wKioL1VyvUXCweg7AAE4iYY8UDg306.jpg "/>
A file or directory in which permission properties have been modified within #-cmin-2:2 minutes; + 2: The file or directory where the permission properties were modified 2 minutes ago. The time unit is minutes.
#查找2分钟之前60分钟之内修改过权限的文件或目录
Find/home-cmin +2-a-cmin-60
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/14/wKiom1Vyu6bzA5CQAAGk-M5D2Ic556.jpg "/>
#-ctime-2:48 the file or directory in which the permission attribute was modified within the hour, or +2:48 the file or directory in which the permission properties were modified before the hour. The time unit is 24 hours, i.e. 2*24=48 hours.
#查找3天之前5天之内修改过权限属性的文件或目录
find/var/log/-ctime +3-a-ctime-5-exec ls-l {} \;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/14/wKiom1Vyu6bj7GXyAAE0TVrI2aE695.jpg "/>
Files or directories that have changed content within #-mmin-2:2 minutes; + 2:2 minutes ago Modified the content of the file # or directory, the time unit is minutes.
#查找1分钟之前30分钟之内修改过文件内容的文件或目录
Find/home-mmin +1-a-mmin-30
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/10/wKioL1VyvUawORMUAAENN7RUJfk650.jpg "/>
A file or directory in which content was modified within #-mtime-2:48 hours, or a file or directory in which the content was modified +2:48 hours ago. The time unit is 24 hours, i.e. 2*24=48 hours.
#查找1天之前30天之内修改过内容的文件或目录
Find/home-mtime +1-a-mtime-30
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/14/wKiom1Vyu6ejCEhUAAIt9JLqmmE924.jpg "/>
#-uid (+ or-) value (0): 10: Indicates less than 10;+1: Indicates size or no +-5: equals 5
#在当前目录下查找uid a =0 file or directory
Find. -uid 0
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/10/wKioL1VyvUfASs3YAAGoxyj7EuY271.jpg "/>
#-gid (+ or-) value (0): 10: Indicates less than 10;+1: Indicates size or no +-5: equals 5
#在当前目录下查找gid a =0 file or directory
Find. -gid 0
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/10/wKioL1VyvUfylq6tAAGkykVAd0I532.jpg "/>
#-name find a file or directory name: You can use the *, + match
#查找/var/log/all files ending with. log
Find/var/log/*.log
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/14/wKiom1Vyu6jR64wIAACp9Ocl_j8224.jpg "/>
#查找当前目录下uid >0,gid<2223 files or directories
Find. -uid +0-gid-2223
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/10/wKioL1VyvUiTqMvJAAIjp_BxZDo454.jpg "/>
#-perm mode:
#-Value: Mode is converted to binary, 1 of the four values must be matched, such as 0700 (111000000).
#0700-7777 are matched to each other and can be understood to be more than 0700 matched
#查找权限大于744的文件或目录, because mode 1th is 7, all 1, so all master
#权限不为7的都不会符合, the group privilege value is 4, 5 (4+1), 7 (4+2+1), and the phase has 1
#符合要求, other permissions require the same as group permissions, so the test catalog meets the requirements
Find. -perm-744
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/14/wKiom1Vyu6nz_TrPAAG7G6nlC2c087.jpg "/>
#+ Value: Mode is converted to binary, four values bits any of the 1 places
#有其中1个值相与等于1就可以了
#+001 matches permissions that are 1, 5 (=4+1), and 7 (=4+2+1) as long as the last permission value is
#查找包含有权限值001的文件或目录
The #user3, User4, and User5 permissions are 001 and 1, so they do not meet the requirements, while DDD
#其他权限中相与有1, so meet the requirements
#+mode can be understood as conforming to the requirements that include this mode pattern
Find. -perm +001
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/10/wKioL1VyvUigAfxCAAIpRepvEpk722.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/14/wKiom1Vyu6mjXm3OAAISliXFUCs415.jpg "/>
#mode: Indicates equals.
#查找权限值等于001的文件或目录
Find. -perm 001
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/10/wKioL1VyvUmAaeU3AAGcs2praGQ029.jpg "/>
#-size File Size:-The numeric representation is less than, + the value is greater than, no-+ + = equals.
#查找大于10k小于30k的文件或目录
Find. -size +10-size-30k
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/14/wKiom1Vyu6riaVnKAALY3mOqUQU023.jpg "/>
#查找大小等于4k的文件或目录, K can be converted to M or G
Find. -size 10k
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/14/wKiom1Vyu6vw4VFYAAHndM7iYYg441.jpg "/>
#-empty: Find an empty directory with a size of 0 bytes file, or no subdirectories or files in the directory
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/10/wKioL1VyvUuQTM3-AAJRXhH2UkM558.jpg "/>
#-exec shell command: Execute shell command on the found file or directory
#查找大于10k小于30k的文件或目录, and copy it to/tmp
Find. -size +10k-size-30k-exec CP-RF {}/tmp \;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/10/wKioL1VyvUvgrHpuAACj5G8J3zw235.jpg "/>
#whereis,-B: Find only binaries,-u: Find files that do not contain the specified type,-B: only the specified
#录查找二进制文件,-M: whenever you find a Help file in the specified directory
#-s: Find source files only in specified directory
Search under #whereis只会在 $PATH path
Whereis ls
#aaa文件在/home, not in $path, so the search is not
Whereis AAA
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/14/wKiom1Vyu6zCunMvAAFZ0a107kg151.jpg "/>
#which, find the executable file and list specific additional information if it is an alias command
which LS
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/14/wKiom1Vyu6yC471rAABkdV4CMEc285.jpg "/>
#locate, search in the database of established files and paths, and change the database before general search
#如果不使用updatedb更新, the newly created file cannot be searched after the system has been started.
#最小化安装是没有locate命令的, yum-y install mlocate installation
#它依赖/var/lib/mlocate/mlocate.db Database
Locate One_day
#新建一个文件abcd123456, and then find, because there is no updatedb, so it is not found file
Touch abcd123456
Locate abcd123456
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/10/wKioL1VyvUyQQKm4AADVX8lpFJw423.jpg "/>
This article is from the "Love On Action" blog, please be sure to keep this source http://1055745601.blog.51cto.com/5003160/1659233
Shell Script (ii)