Difference between revisions of "Global Regular Expression Print"

From 6bit.ch wiki
Jump to navigation Jump to search
(Created page with "= grep = Print lines from text that match patterns, basic regex is used by default</br> == Use == <code>grep /etc/ssh/sshd_config pattern</code> match pattern in /etc/sshd_config, case sensitive</br> == Useful Flags == <code>-E</code> use extended regex</br> <code>-i</code> case insensitive</br> <code>-A x</code> print x lines after matched pattern</br> <code>-B x</code> print x lines before matched pattern</br> <code>-C x</code> print x lines before and after matched...")
 
Line 14: Line 14:
<code>-n</code> print line number from file</br>
<code>-n</code> print line number from file</br>
<code>-o</code> only print matched pattern</br>
<code>-o</code> only print matched pattern</br>
<code>-R</code> search all files in given folder</br>

Revision as of 16:28, 30 December 2022

grep

Print lines from text that match patterns, basic regex is used by default

Use

grep /etc/ssh/sshd_config pattern match pattern in /etc/sshd_config, case sensitive

Useful Flags

-E use extended regex
-i case insensitive
-A x print x lines after matched pattern
-B x print x lines before matched pattern
-C x print x lines before and after matched pattern, results separated by "--"
-n print line number from file
-o only print matched pattern
-R search all files in given folder