Search Directory: find/search range)-name 'search keyword '-typed
Search file: find/search range)-name search keyword-print
For more information, see Linux Command details.
The excerpt is as follows:
· Findpath-option [-print] [-exec-okcommand] {}/;
#-Print: output the searched files to the standard output
#-Execcommand {}/; ----- execute the command operation on the retrieved file. There is a space between {} And /;
#-OK is the same as-exec, but you need to consult the user before the operation
========================================================== ================
-Namefilename # search for a file named filename
-Perm # search by execution permission
-Userusername # search by file owner
-Groupgroupname # search by group
-Mtime-n + n # Find the file based on the file change time.-n indicates that the file is less than n days, and + n indicates that the file is earlier than n days.
-Atime-n + n # query by file access time
-Perm # search by execution permission
-Userusername # search by file owner
-Groupgroupname # search by group
-Mtime-n + n # Find the file based on the file change time.-n indicates that the file is less than n days, and + n indicates that the file is earlier than n days.
-Atime-n + n # search for files based on the file access time.-n indicates that the file is less than n days, and + n indicates that the file is earlier than n days.
-Ctime-n + n # Find the file based on the file creation time.-n indicates that the file is less than n days, and + n indicates that the file is earlier than n days.
-Nogroup # Check for files with no valid group, that is, the file group does not exist in/etc/groups.
-Nouser # Check files with no valid owner, that is, the file owner is not stored in/etc/passwd.
-Newerf1! F2 file search,-n refers to n days or less, + n refers to n days ago
-Ctime-n + n # Find the file based on the file creation time.-n indicates that the file is less than n days, and + n indicates that the file is earlier than n days.
-Nogroup # Check for files with no valid group, that is, the file group does not exist in/etc/groups.
-Nouser # Check files with no valid owner, that is, the file owner is not stored in/etc/passwd.
-Newerf1! F2 # Query files whose modification time is earlier than f1 but earlier than f2
-Typeb/d/c/p/l/f # Check Block devices, directories, character devices, pipelines, symbolic links, and common files.
-Sizen [c] # query objects with a length of n [or n Bytes]
-Depth # search for the local directory before entering the subdirectory
-Fstype # Query files whose change time is newer than f1 but earlier than f2
-Typeb/d/c/p/l/f # Check Block devices, directories, character devices, pipelines, symbolic links, and common files.
-Sizen [c] # query objects with a length of n [or n Bytes]
-Depth # search for the local directory before entering the subdirectory
-Fstype # Query files in a certain type of file system. These file system types can be found in/etc/fstab.
-Mount # The mount point of the file system is not crossed during file query.
-Follow # If a symbolic link file is encountered, the file indicated by the link will be tracked.
-Cpio # Query files in a certain type of file system. These file system types can be found in/etc/fstab.
-Mount # The mount point of the file system is not crossed during file query.
-Follow # If a symbolic link file is encountered, the file indicated by the link will be tracked.
-Cpio # Use the cpio command to back up the matching files to the tape device.
-Prune # ignore a directory
========================================================== ================
$ Find ~ -Name "*. txt" -printtoken: Check the. txt file in home‑home‑and display it
$ Find.-name "*. txt"-print
$ Find.-name "[A-Z] *"-pri26nbsp; # Use the cpio command for matching files to back them up to tape Devices
-Prune # ignore a directory
========================================================== ==================
$ Find ~ -Name "*. txt" -printtoken: Check the. txt file in home‑home‑and display it
$ Find.-name "*. txt"-print
$ Find.-name "[A-Z] *"-print # Query files starting with an uppercase letter
$ Find/etc-name "host *"-print # Query files starting with host
$ Find.-name "commana-z00000000a-z0000000000000--9000000000--90000.txt"-print # query txt files starting with two lower-case letters and two numbers
$ Find.-perm755-print
$ Find.-perm-007-execls-l {}/; # Check all files that can be read and written by the user with-perm777
$ Find.-typed-print
$ Find .! -Typed-print
$ Find.-typel-print
$ Find.-size + 000000c-print # Query files with a length greater than 1 MB
$ Find.-size100c-print # Query files with a length of C
$ Find.-size + 10-print #1 file with a length of over 10 expired blocks = 512 bytes)
$ Cd/
$ Findetchomeapps-depth-print | cpio-ivcdC65536-o/dev/rmt0
$ Find/etc-name "passwd *"-execgrep "cnscn" {}/; # check whether a cnscn user exists
$ Find.-name "yao *" | xargsfile
$ Find.-name "yao *" | xargsecho "">/tmp/core. log
$ Find.-name "yao *" | xargschmodo-w
========================================================== ====================
Find-name1_l * search for files starting with CMDL in the current directory
Find-nameapril * fprintfile searches for files starting with CMDL in the current directory and outputs the results to the file.
Find-nameap *-o-namemay * search for files starting with ap or may
Find/mnt-nametom.txt-ftypevfat find the file named tom.txt under/mntand the file system type is vfat
Find/mnt-namet.txt! -Ftypevfat: Find a file named tom.txt under/mntand the file system type is not vfat.
Find/tmp-namewa *-typel search for files starting with wa and whose type is symbolic link under/tmp
Find/home-mtime-2 check files modified in the last two days under/home
Find/home-atime-1 Query files that have been accessed within 1 day
Find/home-mmin + 60 check files modified 60 minutes ago under/home
Find/home-amin + 30 check files that have been accessed in the last 30 minutes
Find/home-newertmp.txt at/homeview updates to files or directories near tmp.txt
Find/home-anewertmp.txt find files or directories near tmp.txt under/home
Find/home-used-2 list the files or directories that have been accessed within two days after the files or directories have been modified.
Find/home-usercnscn list the files or directories in the/home directory that belong to the user's cnscn
Find/home-uid + 501 list files or directories with user IDs greater than 501 in the/home Directory
Find/home-groupcnscn list/home files or directories with cnscn groups
Find/home-gid501 list files or directories in/home with group id 501
Find/home-nouser: list files or directories that do not belong to local users in/home.
Find/home-nogroup list files or directories in/home that do not belong to the Local Group
Find/home-nametmp.txt-maxdepth4 list/homeinner tmp.txt queries with up to 3 layers of Depth
Find/home-nametmp.txt-mindepth3 from layer 2nd
Find/home-empty
Find/home-size + k to query files larger than K
Find/home-size-512k to query files smaller than KB
Find/home-links + 2 check files or directories with hard connections greater than 2
Find/home-perm0700 to view files or directories with 700 permissions
Find/tmp-nametmp.txt-execcat {}/;
Find/tmp-nametmp.txt-okrm {}/;
Find/-amin-10 # find the files accessed in the last 10 minutes in the system
Find/-atime-2 # find the last 48 hours of access to files in the system
Find/-empty # search for files or folders that are empty in the system
Find/-groupcat # find the groupcat file in the system
Find/-mmin-5 # find the files modified in the last 5 minutes in the system
Find/-mtime-1 # find Files modified in the last 24 hours of the system
Find/-nouser # search for files belonging to the void user in the system
Find/-userfred # search for files belonging to the user FRED IN THE SYSTEM
Query all common files in the current directory
--------------------------------------------------------------------------------
# Find.-typef-execls-l {}/;
-Rw-r -- 1rootroot349282003-02-25./conf/httpd. conf
-Rw-r -- 1rootroot129592003-02-25./conf/magic
-Rw-r -- 1rootroot1802003-02-25./conf. d/README
Query all common files in the current directory and use the ls-l command in the-exec option to list them.
========================================================== ==========
In the/logs directory, find the files whose changes were earlier than 5 days and delete them:
$ Findlogs-typef-mtime + 5-exec-okrm {}/;
========================================================== ==========
Query the files modified on the current day
[Root @ bookclass] # find./-mtime-1-typef-execls-l {}/;
========================================================== ==========
Query the file and ask if you want to display it
[Root @ bookclass] # find./-mtime-1-typef-okls-l {}/;
<Ls.../classDB. inc. php>? Y
-Rw-r -- 1cnscncnscn13709 January 12./classDB. inc. php
[Root @ bookclass] # find./-mtime-1-typef-okls-l {}/;
<Ls.../classDB. inc. php>? N
[Root @ bookclass] #
========================================================== ==========
Query and submit it to awk for processing
[Root @ bookclass] # who | awk '{print $1 usd/t "$2 }'
Cnscnpts/0
========================================================== ==========
Awk --- grep --- sed
[Root @ bookclass] # df-k | awk '{print $1}' | grep-v 'none' | seds "// dev /// g"
File System
Sda2
Sda1
[Root @ bookclass] # df-k | awk '{print $1}' | grep-v 'none'
File System
/Dev/sda2
/Dev/sda1
1) Search for all *. h In/tmp, search for "SYSCALL_VECTOR" in these files, and print out all file names containing "SYSCALL_VECTOR ".
A) find/tmp-name "*. h" | xargs-n50grepSYSCALL_VECTOR
B) grepSYSCALL_VECTOR/tmp/*. h | cut-d': '-f1 | uniq> filename
C) find/tmp-name "*. h"-execgrep "SYSCALL_VECTOR" {}/;-print
2) find/-namefilename-execrm-rf {}/;
Find/-namefilename-okrm-rf {}/;
3) For example, to search for files larger than 3 m on a disk:
Find.-size + 3000k-execls-ld {};
4) copy the find to another place.
Find *. c-execcp '{}'/tmp ';'
If a special file exists, you can use cpio or the following syntax:
Finddir-namefilename-print | cpio-pdvnewdir
6) Search for the files changed from 2013 to 11 to 3016: 36: 37.
# A = 'Find. /-name "* php" '| ls-l -- full-time $ A2>/dev/null | grep "2013-11-3016: 36: 37"
This article is from the "by_Give_up" blog, please be sure to keep this http://501754120.blog.51cto.com/4244111/1302129