Difference between revisions of "Global Regular Expression Print"

From 6bit.ch wiki
Jump to navigation Jump to search
Line 15: Line 15:
<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>
<code>-R</code> search all files in given folder</br>
<code>-v</code> inverse match</br>
<code>-w</code> match whole words only</br>

Revision as of 16:39, 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
-v inverse match
-w match whole words only