gtpo1m5tOperations

ZFILE find-Find a File

Use this command to find files in a specified directory or directory hierarchy.

Requirements and Restrictions

Format




path
is the path of the directory you want to search. If this directory contains other directories, those will be searched as well.

option
specifies search criteria and consists of one or more of the following:

-exec info { } ;
allows you to take any found files and pass the information to another ZFILE command, where info is the command you want to pass information to, the braces ({ }) represent the found files, and the semicolon (;) indicates the end of the -exec option. The ending semicolon (;) must be delimited with a white space and escaped with a backslash (\). For example:
zfile find . \( -name tmp.* -o -name "*.t" \) -exec rm {} \;

first finds all files named tmp and all files with a .t extension. Those files are then passed to the ZFILE rm command (rm) and are subsequently removed.

-group groupname
finds files having the same group owner, where groupname is the group owner you are searching for.

-name pattern
finds file names matching the specified criteria, where pattern is the pattern you are searching for in the file names.

-perm pppp
finds files matching the specified file permissions, where pppp is the permission setting in octal notation. By default, the -perm option finds only those files matching pppp exactly. To find files with permission settings of at least pppp, add a minus sign (-) in front of pppp. For example, zfile find . -perm -444 finds files with a permission value of 444 or higher. For a list of permission values, see ZFILE chmod-Change the Access Permissions of a File or Directory.

-type char
finds files having the same file type, where char is one of the following:

c
Character special file.

d
Directory.

f
Regular file.

l
Symbolic link.

p
Named pipe.

s
Socket file type.

-user fileowner
finds files having the same file owner, where fileowner is the file owner you are searching for.

-a
connects two options with a logical AND.

-o
connects two options with a logical OR.

-print
displays the matching files on the screen.

Additional Information

Examples

The following example finds files with extensions .c and .h in or below your current directory.

+--------------------------------------------------------------------------------+
|User:   ZFILE find ./ -name '*.[ch]'                                            |
|                                                                                |
|System: FILE0001I 08:14:31 START OF DISPLAY FROM find ./ -name '*.[ch]'         |
|        ./abc.h                                                                 |
|        ./file1.c                                                               |
|        ./file2.c                                                               |
|        ./xyz.h                                                                 |
|        END OF DISPLAY                                                          |
|                                                                                |
+--------------------------------------------------------------------------------+

The following example finds all directories in or below your current directory.

+--------------------------------------------------------------------------------+
|User:   ZFILE find . -type d                                                    |
|                                                                                |
|System: FILE0001I 08:14:31 START OF DISPLAY FROM find . -type d                 |
|        ./directory1                                                            |
|        ./directory1/test                                                       |
|        ./directory2                                                            |
|        END OF DISPLAY                                                          |
|                                                                                |
+--------------------------------------------------------------------------------+

The following example finds file names that contain the string qzz and are owned by user bill in directory work.

+---------------------------------------------------------------------------------------------+
|User:   ZFILE find work -name "qzz*" -user bill                                              |
|                                                                                             |
|System: FILE0001I 08:14:31 START OF DISPLAY FROM find work -name "qzz*" -user ...            |
|        work/apache/src/qzz1.c                                                               |
|        work/temp/qzz8.c                                                                     |
|        END OF DISPLAY                                                                       |
|                                                                                             |
+---------------------------------------------------------------------------------------------+

The following example displays the names of all files with the name tmp or with the .xx extension in or below the current directory.

+---------------------------------------------------------------------------------------------+
|User:   ZFILE find . -name "tmp.*" -o -name "*.xx"                                           |
|                                                                                             |
|System: FILE0001I 08:14:31 START OF DISPLAY FROM find . -name tmp -o -name "*.xx"            |
|        ./file1.xx                                                                           |
|        ./tmp.c                                                                              |
|        ./tmp.t                                                                              |
|        END OF DISPLAY                                                                       |
|                                                                                             |
+---------------------------------------------------------------------------------------------+

The following example displays file names with access permission bit settings 777 (read, write, and execute permission for user, group, and other) in or below the current directory.

+---------------------------------------------------------------------------------------------+
|User:   ZFILE find . -perm 777                                                               |
|                                                                                             |
|System: FILE0001I 08:14:31 START OF DISPLAY FROM find . -perm 777                            |
|        ./file1.c                                                                            |
|        ./file2.c                                                                            |
|        ./newdir/test.c                                                                      |
|        END OF DISPLAY                                                                       |
+---------------------------------------------------------------------------------------------+

The following example removes all files named tmp or files ending in .xx in or below the current directory.

+---------------------------------------------------------------------------------------------+
|User:   ZFILE find . \( -name "tmp.*" -o -name "*.xx" \) -exec rm {} \;                      |
|                                                                                             |
|System: FILE0001I 08:14:31 find . \( -... COMPLETED SUCCESSFULLY.  NO OUTPUT TO DISPLAY      |
+---------------------------------------------------------------------------------------------+

The following example displays file names that do not end in .o or .t and are owned by user bill or are part of group pgrms in or below the current directory.

+---------------------------------------------------------------------------------------------+
|User:   ZFILE find . ! \( -name "*.o" -o -name "*.t" \) -a \( -user bill -o -group pgrms \)  |
|                                                                                             |
|System: FILE0001I 08:14:31 START OF DISPLAY FROM find . ! \( -name "*.o" -o -name "...       |
|        ./abc.c                                                                              |
|        ./newdir/new.c                                                                       |
|        ./test2.c                                                                            |
|        END OF DISPLAY                                                                       |
+---------------------------------------------------------------------------------------------+

Related Information