Searching for Content in Files Using the fgrep

You can use the fgrep command to search a file for a literal string or a group of characters. The fgrep command reads all regular expression characters literally. Regular expression metacharacters have no special meaning to the fgrep command, for example a ? character, is interpreted as a question mark, and a $ character is interpreted as a dollar sign.

The syntaxfor the fgrep command is:

fgrep options string filenames

To search for all lines in the file containing a literal asterisk (*) character, perform the command:

$ fgrep '*' /etc/system
*ident  "@(#)system     1.18    97/06/27 SMI" /* SVR4 1.5 */
*
* SYSTEM SPECIFICATION FILE
*
* moddir:
*
*	 Set the search path for modules.  This has a format similar to the
*	 csh path variable. If the module isn't found in the first directory
*	 it tries the second and so on. The default is /kernel /usr/kernel
... (output truncated)

Leave a Comment

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top