gtpo1m5u | Operations |
Use this command to search files for one or more patterns.
Requirements and Restrictions
Format
|
Additional Information
ZFILE HELP grep
ZFILE HELP
ZFILE ?
ZFILE ls -l | grep JanThe result is filtered output from the ZFILE ls command displaying only the lines containing the word Jan in any position.
You can use pipes only with a combination of ZFILE commands where the command on the left-hand side of the pipe provides data through stdout and the right-hand side accepts data through stdin.
You can redirect the standard output (stdout) stream from the display terminal to a file by specifying one of the redirection characters (> or >>) followed by the file name to which you want the output written. The > character writes the output to a file. The >> character appends the output to an existing file.
You can redirect the standard error (stderr) stream from the display terminal to a file by specifying one of the redirection characters (2> or 2>>) followed by the file name to which you want the error output written. The 2> character writes the error output to a file. The 2>> character appends the error output to an existing file.
User: ZFILE echo \$PATH is $PATH System: $PATH is /bin:/usr/bin:.
left angle bracket (<) | right angle bracket (>) | ampersand (&) |
backquote (`) | backslash (\) | dollar sign ($) |
double quotation mark (") | new-line (\n) | left parenthesis ( ( ) |
right parenthesis ( ) ) | semicolon (;) | single quotation mark (') |
blank space | tab | vertical bar (|) |
asterisk (*) | equal sign (=) | left square bracket ( [ ) |
number sign (#) | question mark (?) | tilde (~) |
Examples
In the following example, all files with the .h extension are searched for regular expression T.F.
+--------------------------------------------------------------------------------+ |User: ZFILE grep T.F *.h | | | |System: FILE0001I 08:14:31 START OF DISPLAY FROM grep T.F *.h | | bytecode.h: BGET_FREAD(ary, 256, 2); | | config.h:/* has_FSTATVFS: | | perl.h:#if defined(TPF) && defined(I_SYS_TIMES) | | END OF DISPLAY | | | +--------------------------------------------------------------------------------+
In the following example, all files with the .c extension are searched for patterns TPF and tpf_fork.
+--------------------------------------------------------------------------------+ |User: ZFILE grep -e TPF -e tpf_fork *.c | | | |System: FILE0001I 08:14:31 START OF DISPLAY FROM grep -e TPF -e tpf_fork *.c | | pp_sys.c:#ifdef TPF | | tpf.c: struct tpf_fork_input fork_input; | | util.c:#if !defined(VMS) && !defined(TPF) | | END OF DISPLAY | +--------------------------------------------------------------------------------+
In the following example, files tpf.c and tpf.h are searched for pattern setenv. Only file tpf.c contains the specified pattern.
+--------------------------------------------------------------------------------+ |User: ZFILE grep -l setenv tpf.c tpf.h | | | |System: FILE0001I 08:14:31 START OF DISPLAY FROM grep -l setenv tpf.c tpf.h | | tpf.c | | END OF DISPLAY | +--------------------------------------------------------------------------------+
In the following example, files beginning with either the letter s or the letter t and ending with either the .c or .h extension are searched for pattern print. The options indicate that the file name and the number of times that pattern is in that file will be displayed.
+--------------------------------------------------------------------------------+ |User: ZFILE grep -c print* [st]*.[ch] | | | |System: FILE0001I 08:14:31 START OF DISPLAY FROM grep -c print* [st]*.[ch] | | sv.c:119 | | sv.h:0 | | taint.c:0 | | tpf.c:2 | | END OF DISPLAY | +--------------------------------------------------------------------------------+
In the following example, all files are searched for pattern has_fork. The -i parameter indicates that the case in the pattern will be ignored.
+--------------------------------------------------------------------------------+ |User: ZFILE grep -i has_fork * | | | |System: FILE0001I 08:14:31 START OF DISPLAY FROM grep -i has_fork * | | util.c:#ifdef HAS_FORK | | END OF DISPLAY | +--------------------------------------------------------------------------------+
In the following example, file util.c is searched for patterns listed on separate lines in file file1. For this example, file1 contains the following:
TPF HAS_FORK
+--------------------------------------------------------------------------------+ |User: ZFILE grep -f file1 util.c | | | |System: FILE0001I 08:14:31 START OF DISPLAY FROM grep -f file1 util.c | | #if !defined(VMS) && !defined(TPF) /* VMS' my_setenv() is in VMS.c */ | | #if (!defined(DOSISH) || defined(HAS_FORK) | | END OF DISPLAY | +--------------------------------------------------------------------------------+
Related Information
See Information Technology--Portable Operating System Interface for Computer Environments (POSIX) for more information about the POSIX standards.