Linux command-find {find}

Source: Internet
Author: User

An order to explain

Common example:find Path-option [-print] [-exec-ok command] {} \;

The directory path that the Path:find command looks for. For example, use. To represent the current directory, and/to represent the system root directory.

The-print:find command outputs the matched file to standard output.

The-exec:find command executes the shell command given by the parameter to the matching file. The corresponding command is in the form of ' command ' {} \;, note the space between {} and \;

-ok: The same as-exec, except that the shell command given by the parameter is executed in a more secure mode, prompting the user to determine whether to execute before executing each command.

#-print output the found file to the standard output #-exec command {} \; --the command operation of the file to be traced, {} and \; There are spaces #-ok and-exec the same, except to consult the user example before the operation: find. -name. SVN | Xargs RM-RF

Two application examples

=======================================================================================

-name filename #查找名为filename的文件

-perm #按执行权限来查找

-user username #按文件属主来查找

-group GroupName #按组来查找

-mtime-n +n #按文件更改时间来查找文件,-n means n days or less, +n means n days ago

-atime-n +n #按文件访问时间来查GIN: 0px ">

-ctime-n +n #按文件创建时间来查找文件,-n means n days or less, +n means n days ago

-nogroup #查无有效属组的文件 that the genus of the file does not exist in the/etc/groups

-nouser                              #查无有效属主的文件, that is, the owner of the document does not exist in the/etc/passwd-newer    F1!f2                    #找文件,-n refers to +n, n days ago  -ctime   -+n                    #按文件创建时间来查找文件,-n refers to +n or less than n days ago  -nogroup                             #查无有效属组的文件, that is, the genus of the file does not exist in/etc/groups-nouser                               #查无有效属主的文件, that is, the owner of the document does not exist in the/etc/passwd-newer   F1!f2                    #查更改时间比f1新但比f2旧的文件-type     b/d/c/p/l/f             #查是块设备, directories, character devices, Pipelines, symbolic links, ordinary files-size      n[c]                      #查长度为n块 [or N bytes] of file-depth                         #使查找在进入子目录前先行查找完本目录-fstype                              # Check the change time than F1 new but older than F2 file-type    b/d/c/p/l/f              #查是块设备, directories, character devices, pipelines, symbolic links, Common Files-size      n[c]                      #查长度为n块 [or N-byte] file-depth                                #使查找在进入子目录前先行查找完本目录-fstype                               #查位于某一类型文件系统中的文件, these file system types are usually found in/etc/fstab-mount                              #查文件时不跨越文件系统mount点-follow                              #如果遇到符号链接文件, Just follow the link to the file-cpio    %;           # Files located in a type of file system, which are typically-mount               can be found in/etc/fstab               #查文件时不跨越文件系统mount点-follow                               #如果遇到符号链接文件, just follow the link to the document referred to-cpio                                  #对匹配的文件使用cpio命令, back them up to tape devices-prune                               #忽略某个目录

=======================================================================================

$find ~-name "*.txt"-print #在 $HOME. txt file and displays

$find.    -name "*.txt"-print $find. -name "[a-z]*"-print #查以大写字母开头的文件

$find/etc-name "host*"-print #查以host开头的文件

$find. -name "[A-z][a-z][0–9][0–9].txt"-print #查以两个小写字母和两个数字开头的txt文件

$find.   -perm 755-print $find.      -perm-007-exec ls-l {} \; #查所有用户都可读写执行的文件同-perm 777

$find.   -type d-print $find.   !   -type d-print $find. -type L-print

$find. -size +1000000c-print #查长度大于1Mb的文件

$find. -size 100c-print # Check for files of length 100c

$find. -size +10-print #查长度超过期作废10块的文件 (1 block = 512 bytes)

$CD/$find etc Home Apps-depth-print |   Cpio-ivcdc65536-o/dev/rmt0 $find/etc-name "passwd*"-exec grep "Cnscn" {} \; #看是否存在cnscn用户

$find. -name "yao*" | Xargs file $find.   -name "yao*" | Xargs echo "" >/tmp/core.log $find. -name "yao*" | Xargs chmod o-w

=======================================================================================

Find-name april* #在当前目录下查找以april开始的文件

Find-name april* fprint file #在当前目录下查找以april开始的文件, and outputs the result to file

Find-name ap*-o-name may* #查找以ap或may开头的文件

Find/mnt-name tom.txt-ftype vfat #在/mnt to find files with the name Tom.txt and file system type VFAT

Find/mnt-name T.txt! -ftype vfat #在/mnt to find files with name Tom.txt and file system type not VFAT

Find/tmp-name wa*-type L #在/tmp looking for a file named WA with a type of symbolic link

Find/home-mtime-2 #在/Home search for files that have changed in the last two days

Find/home-atime-1 #查1天之内被存取过的文件

Find/home-mmin +60 #在/Home Check the files that were changed 60 minutes ago

Find/home-amin +30 #查最近30分钟前被存取过的文件

Find/home-newer tmp.txt #在/home update time is closer than Tmp.txt file or directory

Find/home-anewer tmp.txt #在/Home search for files or directories that have access times closer than Tmp.txt

Find/home-used-2 #列出文件或目录被改动过之后, files or directories accessed within 2nd

Find/home-user CNSCN #列出 files or directories in the/home directory that belong to the user Cnscn

Find/home-uid +501 #列出 A file or directory with a user ID greater than 501 in the/home directory

Find/home-group CNSCN #列出 files or directories in the/home group as CNSCN

Find/home-gid 501 #列出 A file or directory with a group ID of 501 inside/home

Find/home-nouser #列出 files or directories that do not belong to local users in/home

Find/home-nogroup #列出 files or directories that are not part of a local group in/home

Find/home-name tmp.txt-maxdepth 4 #列出/home with a depth of up to 3 levels in Tmp.txt check

Find/home-name tmp.txt-mindepth 3 #从第2层开始查

Find/home-empty #查找大小为0的文件或空目录

Find/home-size +512k #查大于512k的文件

find/home-size-512k #查小于512k的文件

Find/home-links +2 #查硬连接数大于2的文件或目录

Find/home-perm 0700 #查权限为700的文件或目录

Find/tmp-name tmp.txt-exec Cat {} \;

Find/tmp-name tmp.txt-ok rm {} \;

Find/-amin-10 #查找在系统中最后10分钟访问的文件

Find/-atime-2 #查找在系统中最后48小时访问的文件

Find/-empty #查找在系统中为空的文件或者文件夹

Find/-group cat #查找在系统中属于 groupcat files

Find/-mmin-5 #查找在系统中最后5分钟里修改过的文件

Find/-mtime-1 #查找在系统中最后24小时里修改过的文件

Find/-nouser #查找在系统中属于作废用户的文件

Find/-user Fred #查找在系统中属于FRED这个用户的文件

Linux command-find {find}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.