Introduction to the find and xargs commands in AIX
Source: Internet
Author: User
[Plain] www.2cto. comfind file search command format: findpathnameoptions [-print-exec-OK] pathname: directory path-print: the matching file is output to the standard output-exec: pair...
Description of the find command and xargs command in AIX [plain] www.2cto.com find File command format: find pathname options [-print-exec-OK] pathname: directory path-print: matching file output to standard output-exec: execute the shell command given by this parameter on the matching file-OK: same as-exec, before executing the command, the "find" command option is displayed every time-name: searches for files by file name ~ Indicates the $ HOME directory of the current user. indicates the current directory and sub-directory./etc indicates searching for files in the/etc directory./indicates searching from the root directory. use caution. eg. find ~ -Name "*. txt "-print-perm: Use the octal representation of the file to find the file according to the file permission. rwxrwxrwx (777) eg. find. -perm-755-print-prune: it is not found in the currently specified directory. if The-depth option is used at the same time, ignore this option to ignore the bin directory eg under/apps. find/apps-name "/apps/bin"-prun-o-print: in the/apps Directory, find all files except the/apps/bin directory-user: search for the file eg by file owner. find ~ -User scott-print (find the files in the scott's home directory) find/etc-user tom-print (find the files that belong to tom in the/etc directory)-nouser: find the file without a valid owner. if the owner of the file is not in/etc/passwd, find the file that has been deleted by the owner account. find/home-nouser print-group: find the file eg according to the group to which the file belongs. find/apps-group maid-print find/apps Directory files belonging to the maid User group-nogroup: find files without a valid group, that is, the file group is not in/etc/groups. find/-group-print (search for files without groups from the root directory)-mtime-n + n: search for files (-atime,-ctime)-n: file change time plus n days from now: File change time from now N days ago. find/-mtime-5-print (search for files within five days from the root directory) find/var/adm-mtime + 3-print (Files 3 days ago) -newer newest_file1! Oldest_file2: find the file for which the change time is newer than file1, but longer than file2. -type: find a type of file, B: block device file d: Directory c: Character device file p: pipeline File l: symbolic link file f: common file eg. find/etc-type d-print (find all directories under the/etc directory) find .! -Type d-print (find files other than directories in the current directory) find/etc-type l-print (find all the linked files in the/etc directory) -size n [c]: searches for files with a length of n blocks. c indicates that the file length is calculated in bytes. find. -size + bytes 00C-print (find files larger than 1 MB in the current directory) find/home/apache-size 100c-print (find the file exactly 100 bytes in the/home/apache Directory) find. -size + 10-print (search for files with a length of 10 blocks in the current directory (1 = 512 bytes)-depth: First, search for files in the current directory, then search for eg in its word directory. find/-name "CON. FILE "-depth-print (the key first searches for matching all files and then searches for them in the word directory)-mount: Does not span the mount point of the file system when searching for files. find. -name "*. XC "-mount-print (find the files ending with XC in the current file system under the current directory)-cpio: Use the cpio command for matching files, back up these files to the tape device-fstype: find the files in a certain type of file system. These file system types can usually be found in the configuration file/etc/fstab, the configuration file contains information about the file system in the system-follow: If the find command encounters a symbolic link file, it traces the file-exec-OK: you can execute shell commands in any form, such as grep "GetStr" eg. find. -type f-exec ls-l {}\; (find common files in the current directory, find the week, and execute the ls-l command) find logs-type f-mtime + 5-exec rm {}\; (find The common file in the logs directory five days ago, and then delete it.) find. -name "*. LOG "-mtime + 5-OK rm {}\; (find and delete the file that ended 5 days ago in the current directory) examples 1. find $ HOME-print find ~ -Print 2. find all files in the current directory with 0 size [developer]/usr/xxxx/src> find. -type f-size 0-exec ls-l {}\;-rw-r -- 1 xxxx group 0 Sep 14. /cds/120031/declare-rw-r -- 1 xxxx group 0 Jul 25 2011. /testfortest/S11100/123.fe-rw-r -- 1 xxxx group 0 Jul 27 2011. /zzs/ZZS403/ZZS403.fe-rw-r -- 1 xxxx group 0 Jul 27 2011. /zzs/ZZS403/ZZS404.fe-rw-r -- 1 xxxx group 0 Jul 27 2011. /zzs/ZZS403/456.fe-rw-r -- r -- 1 xxxx group 0 Aug 17 :46. /zzs/zzs020-rw-r -- 1 xxxx group 0 Aug 24 :06. /zzs/ZZA212.-rw-r -- 1 xxxx group 0 Aug 15 2011. /tmp/123.fe-rw-r -- 1 xxxx group 0 Aug 15 2011. /tmp/456.fe-rw-r -- 1 xxxx group 0 Aug 15 2011. /tmp/ZZS403.fe-rw-r -- 1 xxxx group 0 Aug 15 2011. /tmp/ZZS404.fe xargs when using the-exec command, the find command will pass all matching files to exec for execution. this command has parameter restrictions. if the command is too long, an error such as "parameter column too long" or "parameter overflow" is reported.-each time the xargs command Obtain a part of the file, and then execute the command. not all files are obtained together. [Development]/usr/xxxx/ytcclb> find. -type f-print | xargs file. /myfile: commands text. /first2: commands text. /test. SQL: in the commands text query/apps/audit Directory, all users have the read and write permissions and revoke the write permissions of other user groups: find/apps/audit-perm-7-print | xargs chmod o-w queries all common files and searches for the word "device: find/-type f-print | xargs grep "device" searches for all common files in the current directory and searches for the word "find" in DBO. -name * \-type f-print | xargs grep "DBO" note \ escape
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.