grep
Option
Function
-i
case-insensitve search (case-sensitive by default)
-v
exclude a certain pattern
-o
print only the matched pattern (line by default)
-q
quiet mode (no output, interested in the return status)
-E
extended regex (regex instead of basic patterns)
Multiple Patterns
Substring
PCRE
Extract whatever comes after Host:
.
o
prints only the matched parts of the line and not the entire line.P
activates Perl-compatible regular expressions (PCRE), in this case,\K
:. This is a special feature in Perl-compatible regular expressions that resets the starting point of the match, that is, only the characters after\K
will be included in the output.
Last updated
Was this helpful?