Searches a file for a literal string.
fgrep [-h] [-i] [-s] [-v] [ -w ] [-x] [ -y ] [ [-b] [-n] | [-c | -l | -q ] ] [-pSeparator] {Pattern | -ePattern | -fStringFile} [File...]
The fgrep command searches the input files specified by the File Parameter (standard input by default) for lines matching a pattern. The fgrep command searches specifically for Pattern parameters that are fixed strings. The fgrep command displays the file containing the matched line if you specify more than one file in the File parameter.
- The fgrep command is the same as the grep command with the -F flag, except that error and usage messages are different and the -s flag functions differently.
- Lines are limited to 2048 bytes.
- Paragraphs (under the -p flag) are currently limited to a length of 5000 characters.
- Do not run the grep command on a special file because it produces unpredictable results.
- Input lines should not contain the NULL character.
- Input files should end with the new line character.
- Although some flags can be specified simultaneously, some flags override others. For example, if you specify -l and -n together, only file names are written to standard output.
This command returns the following exit values:
0 | A match was found. |
1 | No match was found. |
>1 | A syntax error was found or a file was inaccessible (even if matches were found). |
fgrep"strcpy"*.c
This searches for the string strcpy in all files in the current directory with names ending in the .c character string.
fgrep-c"{"pgm.c fgrep-c"}"pgm.c
This displays the number of lines in pgm.c that contain left and right braces.
If you do not put more than one { (left brace) or one } (right brace) on a line in your C programs, and if the braces are properly balanced, the two numbers displayed are the same. If the numbers are not the same, you can display the lines that contain braces in the order that they occur in the file with:
egrep "{|}" pgm.c
fgrep-l"strcpy"*.c
This searches the files in the current directory that end with .cand displays the names of those files that contain the strcpy string.
/usr/bin/fgrep | Contains the fgrep command. |
/bin/fgrep | Symbolic link to the fgrep command. |
The ed command, egrep command, grep command, sed command.
Files Overview in AIX Version 4.3 System User's Guide: Operating System and Devices introduces you to files and the way you can work with them.
Input and Output Redirection Overview in AIX Version 4.3 System User's Guide: Operating System and Devices describes how the operating system processes input and output.