Name
grep — Searches for matching patterns
Synopsis
grep [-c -i -n -v]searchPattern[objectName]
Description
grep
searches the named shell object for
lines containing a match to the given search pattern. Matching lines
are written to standard output. Regular expressions are not currently
supported.
If no object is specified on the
command line, grep will read from stdin. If
stdin is the console, you may type in lines of
text. Enter a “.” all by itself at
the beginning of a line to finish.
Options
-
-c Just prints count of matching lines; with
-v, counts non-matching lines-
-i Ignores case when comparing text with search pattern
-
-n Shows line numbers of matches found
-
-v Shows non-matching lines instead of matching lines
Example
JXTA>grep -i -n dog GroceryList3:Hot dogs 7:Dog food JXTA>cat GroceryList | grep -c dog2
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access