December 2018
Beginner
320 pages
8h 57m
English
Grep (short for Global Regular Expression Print) is a command that is used extensively to as a text search tool in text files. It searches for a pattern in a file and prints the corresponding line, which contains the matching pattern. It scans files for specified patterns and can be used with regular expressions, as well as text strings. Its syntax is as follows:
$ grep [options] pattern [files]
The following table demonstrates when the grep command is used:
|
Command |
Usage |
|
grep 'student' /etc/passwd |
Search for a string, student, in a file, /etc/passwd, and print all matching lines |
|
grep -v 'student' /etc/passwd |
Print all lines that do not contain the string student |
|
grep -i 'STUDENT' /etc/passwd ... |
Read now
Unlock full access