December 2015
Beginner
306 pages
5h 2m
English
The g/RE/p stands for globally search for the regular expression (RE) and print out the line.
Return status – success 0, pattern not found 1, file not found 2.
$ ps -ef | grep root
The preceding command will show all processes running currently whose user ID is "root".
$ ll /proc | grep "cpuinfo"
The preceding command will show the file with the name cpuinfo from the /proc directory.
$ grep –lir "text" * // only file names // $ grep –ir "text" dir_name // show lines of files //
We will try the following commands on the love.txt file:
|
Metacharacter |
Function |
Example |
Description |
|---|---|---|---|
|
|
Beginning-of-line anchor |
|
Will display all lines beginning with |
|
|
End-of-line anchor |
|
Will display ... |