find Command Purpose Finds files with a matching expression. Syntax find Path ... Expression Description The find command recursively searches the directory tree for each specified Path, seeking files that match a Boolean expression written using the terms given in the following text. The output from the find command depends on the terms specified by the Expression parameter. The find command does not support the 4.3 BSD fast find syntax. Expression Terms Note: In the following descriptions, the Number variable speci- fies a decimal integer that can be specified as +Number (more than Number), -Number (less than Number), or Number (exactly Number). \( Expression \) True if the expression in parentheses is true. -cpio Device Writes the current file to the specified device in the cpio command format. -depth Always true. Causes the descent of the directory hierar- chy to be done so that all entries in a directory are affected before the directory itself is affected. This can be useful when the find command is used with the cpio command to transfer files that are contained in directories without write permission. -exec Command True if the specified command runs and returns a 0 value as exit status. The end of the specified command must be punctuated by a quoted or escaped semicolon. A command parameter {} (braces) is replaced by the current path name. -fstype Type True if the file system to which the file belongs is of the specified type, where the Type variable has a value of jfs (journaled file system) or nfs (networked file system). -group Group True if the file belongs to the specified group. If the value of the GroupName variable is numeric and does not ap- pear in the /etc/group file, it is interpreted as a group ID. -nogroup True if the file belongs to a group not in the /etc/group database. -inum Number True if file has an i-node matching the value of the Number variable. -links Number True if the file has the specified number of links. See the ln command for a description of links. -ls Always true. Causes the current path name to be printed to- gether with its associated statistics. These statistics include the following: * I-node number * Size in kilobytes (1024 bytes) * Protection mode * Number of hard links * User * Group * Size in bytes * Modification time. If the file is a special file, the size field contains the major and minor device numbers. If the file is a symbolic link, the path name of the linked-to file is printed preceded by the -> (minus, greater than) symbols. The format is identical to that of the ls -gilds command. Note: Formatting is done internally, without executing the ls command. -name File True if value of the File variable matches the file name. You can use wildcard (pattern-matching) characters, pro- vided they are quoted. In an expression such as [a-z], the minus means "through," according to the current collating sequence. A collating sequence may define equivalence classes for use in character ranges. See the "National Language Support Overview for Programming" in AIX Version 3.2 General Programming Concepts for more information on collating sequences and equivalence classes. -newer File True if the current file has been modified more re- cently than the file indicated by the File variable. -ok Command The same as the -exec primary, except that the find command asks you whether it should start the specified command. An affirmative response starts the command. The end of the specified command must be punctuated by a quoted or escaped semi- colon. -perm OctalNumber True if the file-permission code of the file exactly matches the octal number specified by the OctalNumber variable (see the chmod command for an explanation of file per- missions). The OctalNumber parameter may be up to three octal digits. If you want to test the higher-order permission bits (the set-user-ID mode bit or set-group-ID mode bit, for example), prefix the OctalNumber parameter with a - (minus sign). This makes more flag bits significant and also changes the comparison to: (CurrentFilePermissions&OctalNumber)==OctalNumber -print Always true. Causes the current path name to be displayed. Specifies the default primary if none is stated on the command line, and is implicit for any expression specified by the Expression variable without an -exec, -ok, or -print primary be- ing explicitly stated. -prune Always true. Stops the descent of the current path name if it is a directory. If the -depth flag is specified, the -prune flag is ignored. -size Number True if the file is the specified Number of blocks long (512 bytes per block). The file size is rounded up to the nearest block for comparison. -size Numberc True if the file is exactly the specified Number bytes long. Adding c to the end of the Number parameter indi- cates that the size of the file is measured in individual bytes not blocks. -atime Number True if the file has been accessed in the number of 24-hour periods specified in the Number parameter, plus one 24-hour period. See examples in the Examples section. -ctime Number True if the file i-node has been changed in the specified number of 24-hour periods. -mtime Number True if the file has been modified in the specified number of 24-hour periods. -type Type True if the Type variable specifies one of the follow- ing values: b Block special file c Character special file d Directory f Plain file l Symbolic link p FIFO (a named pipe) s Socket -user User True if the file belongs to the specified user. If the value of the User variable is numeric and does not appear as a login name in the /etc/passwd file, it is interpreted as a user ID. -nouser True if the file belongs to a user not in the /etc/passwd database. -xdev Always true. Prevents the find command from traversing a file system different from the one specified by the Path parame- ter. These expressions can be combined using the following operators in the order of decreasing precedence: 1. A group of expressions and operators in parentheses (parentheses are special to the shell and must be escaped). 2. The negation of an expression ('!' represents the unary NOT operator). 3. Concatenation of expressions (the AND operation is implied by the juxtaposition of two primaries or made explicit by the inclu- sion of the optional -a operator). 4. Alternation of expressions (-o is the OR operator). Exit Status This command returns the following exit values: 0 All Path operands were traversed successfully. >0 An error occurred. Examples 1. To list all files in the file system with a given base file name, enter: find / -name .profile -print This searches the entire file system and writes the complete path names of all files named .profile. The / (slash) tells the find command to search the root directory and all of its subdirec- tories. In order not to waste time, it is best to limit the search by specifying the directories where you think the files might be. 2. To list files having a specific permission code in the current directory tree, enter: find . -perm 0600 -print This lists the names of the files that have only owner-read and owner-write permission. The . (dot) tells the find command to search the current directory and its subdirectories. See the chmod command for an explanation of permission codes. 3. To search several directories for files with certain permis- sion codes, enter: find manual clients proposals -perm -0600 -print This lists the names of the files that have owner-read and owner- write permission and possibly other permissions. The manual, clients, and proposals directories and their subdirectories are searched. In the previous example, -perm 0600 selects only files with permission codes that match 0600 exactly. In this example, -perm -0600 selects files with permission codes that allow the accesses indicated by 0600 and other accesses above the 0600 lev- el. This also matches the permission codes 0622 and 2744. 4. To list all files in the current directory that have been changed during the current 24-hour period, enter: find . -ctime 0 -print 5. To search for regular files with multiple links, enter: find . -type f -links +1 -print This lists the names of the ordinary files (-type f) that have more than one link (-links +1). Note: Every directory has at least two links: the entry in its parent directory and its own . (dot) entry. The ln command ex- plains multiple file links. 6. To find all accessible files whose path name contains find, enter: find . -name '*find*' -print 7. To remove all files named a.out or *.o that have not been ac- cessed for a week and that are not mounted using nfs, enter: find / \(-name a.out -o -name '*.o'\) -atime + 6 -exec \ rm {} \; -o -fstype nfs Note: The number used within the -atime expression is +6. This is the correct entry if you want the command to act on files not accessed for more than a week (seven 24-hour periods). 8. To print the path names of all files in or below the current directory, except the directories named SCCS or files in the SCCS directories, enter: find . -name SCCS -prune -o -print To print the path names of all files in or below the current directory, including the names of SCCS directories, enter: find . -print -name SCCS -prune 9. To search for all files that are exactly 414 bytes long, enter: find . -size 414c -print 10. To find and remove every file in your home directory with the .c suffix, enter: find /u/arnold -name "*.c" -exec rm {} \; Every time the find command identifies a .c file, the rm command deletes that file. The rm command is the only parameter speci- fied for the -exec expression. The {} (braces) represent the current path name. Implementation Specifics A collating sequence in Multibyte Code Set Support does not de- fine equivalence classes for use in character ranges. To avoid unpredictable results when using a range expression to match a class of characters, use a character class expression rather than a standard range expression. This command is part of Base Operating System (BOS) Runtime. Files /usr/bin/find Contains the find command. /bin/find Contains the symbolic link to the find command. /etc/group Contains a list of all known groups. /etc/passwd Contains a list of all known users. Related Information Backup Overview for System Management in AIX Version 3.2 System Management Guide: Operating System and Devices introduces archiv- ing methods, including the use of the cpio command. Directories Overview in AIX Version 3.2 Files Reference describes the structure and characteristics of directories in the file system. Files Overview in AIX Version 3.2 System User's Guide: Base and Devices describes files, file types, and how to name files. Understanding File and Directory Access Modes in AIX Version 3.2 System User's Guide: Base and Devices introduces file ownership and permissions to access files and directories. Input and Output Redirection Overview in AIX Version 3.2 System User's Guide: Base and Devices describes how the operating system processes input and output. Shells Overview in AIX Version 3.2 System User's Guide: Base and Devices describes shells, the different types of shells, and how shells affect the way commands are interpreted. find Command for the Kernel Debug Program Purpose Searches storage. Syntax find Pattern [ Address [ EndAddress [ Alignment ] ] ] Description The find command searches storage for a pattern beginning at the address specified by the Address parameter. If the specified ar- gument is found, the search stops and storage containing the specified argument is displayed. The address of the storage is placed into the fx variable. The following defaults apply to the first execution of the find command: * Address = 0 * EndAddress = 0xFFFFFFFF * Alignment = 1 (byte alignment) An asterisk (*) can be substituted for any of the parameters. An asterisk causes the find command to use the value for that param- eter that was used in the previous execution of the command. Note: Use the find command only while running the kernel debug program. Examples 1. To find the first occurrence of 7c81 in virtual memory start- ing at 0, enter: find 7c81 2. To find the first occurrence of the string TEST, enter: find "TEST" 3. To find the first occurrence of 7c81 after address 10000, enter: f 7c81 10000 4. To find the first occurrence of 7c81 between 0 and the user- defined top variable, enter: f 7c81 0 top 5. To find the first occurrence of 7c81 starting at the last ad- dress used, enter: find 7c81 * 6. To find the first of occurrence of 7c81 starting at the last address used and aligned on a halfword, enter: f 7c81 * * 2 7. To find the next occurrence of 7c starting at 1 plus the last address at which the find command stopped, enter: f 7c fx+1 * 2 Implementation Specifics This command is part of Base Operating System (BOS) Runtime. Related Information Error Messages for the Kernel Debug Program in AIX Version 3.2 General Programming Concepts. List of Kernel Debug Program Commands in AIX Version 3.2 General Programming Concepts. The Kernel Debug Program Overview in AIX Version 3.2 General Programming Concepts. ================================================================= ================================================================= find Subcommand for the xde Command Purpose Searches for a pattern within the file window. Syntax find [ forward | backward ] [ Expression ] Description The find subcommand searches the File window in the specified direction for text matching the specified expression. The de- fault direction is forward. The search starts from the line after the current location or the current focus depending on which changed most recently. Multiple word patterns should be enclosed in double quotation marks. If no expression is speci- fied, the Find dialog is started to obtain the necessary expres- sion. The matching text is indicated by the focus indicator and scrolled into the file window. Note: The find subcommand can be started only while running the xde program. Examples To find the pattern "this string," enter: find "this string" Related Information xde Debug Program Overview and Using the xde Debug Command in AIX Version 3.2 General Programming Concepts. The xde command. List of xde Subcommands in AIX Version 3.2 General Programming Concepts. xde Find Dialog in AIX Version 3.2 General Programming Concepts.