User Tools

Site Tools


tool:software:grep

Differences

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

Link to this comparison view

tool:software:grep [2020/07/02 19:29] (current)
rjt created
Line 1: Line 1:
 +====== Grep ======
 +I don't make great use of all the gnu tools, but they sure come in handy some times.
  
 +===== Use =====
 +
 +Basic use is searching a file for a particular term, and grep spitting out each line that term occurs in.
 +
 +''grep [term] [file]''
 +
 +With the ''E'' flag you can use the usual regular expressions. So searching for either of two terms:
 +
 +''grep -E '[term1]|[term2]' [file]''
 +
 +Otherwise there's also a utility called egrep.
 +
 +NB: ''[file]]'' doesn't even have to be a file, you can use wildcard sand things there too.
 +
 +There's probably a beter way to do this, but to search for instances with all terms I use a pip, like:
 +
 +''grep '[term1]' [file] | grep '[term2]'''
 +
 +===== See Also =====
 +  * [[https://www.gnu.org/software/grep/manual/html_node/index.html|GNU Grep 3.4]] on gnu.org
 +  * [[wp>Grep]]
 +  * [[github>phiresky/ripgrep-all]] - Searches more file kinds.
 +  * [[https://sourceforge.net/projects/multiline-grep/|Multiline Grep]]
 +  * [[form:plaintext]]
 +
 +{{tag>unix linux cli}}
tool/software/grep.txt · Last modified: 2020/07/02 19:29 by rjt