User Tools

Site Tools


grep:basic_usage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
grep:basic_usage [2020/08/22 10:57] 192.168.1.1grep:basic_usage [2020/08/22 11:02] (current) 192.168.1.1
Line 126: Line 126:
 **NOTE:**  The **-i** option will treat upper and lower case as equivalent while matching the search string. **NOTE:**  The **-i** option will treat upper and lower case as equivalent while matching the search string.
 </WRAP> </WRAP>
 +
 +----
 +
 +===== Exact Matches Only =====
 +
 +<code bash>
 +grep -x "boo" filename
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  The **-x** option looks for eXact matches only.
 +
 +The result in this example will print nothing, because there are no lines that only contain the pattern **boo**.
 +</WRAP>
 +
 +----
 +
 +===== Add additional lines of context =====
 +
 +<code bash>
 +grep -A2 "mach" filename
 +</code>
 +
 +returns:
 +
 +<code bash>
 +machine
 +boots
 +bungie
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  The **A** option will print out the search string plus a number of additional lines.
 +
 +In this example 2 additional lines.
 +</WRAP>
 +
  
grep/basic_usage.1598093837.txt.gz · Last modified: 2020/08/22 10:57 by 192.168.1.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki