linux grep usage when receiving cat output code example

Example 1: linux grep

# EXAMPLE 1: look for any files (with names ending in ".c++") for the text "::MethodA("
grep "::MethodA(" *.c++

# EXAMPLE 2: display only the matching file names (not the row too) of the matches
grep -l "MethodA(" *.c++

# SYNTAX
# grep [optional-filters] "<your-string-to-search>" <files-to-search>


# OPTIONAL-FILTERS
# +--------+----------------------------------------------------------------------------+
# | OPTION |  DESCRIPTION                                                               |
# +--------+----------------------------------------------------------------------------+
# |  -e    |  pattern                                                                   |
# |  -i    |  Ignore uppercase vs. lowercase.                                           |
# |  -v    |  Invert match.                                                             |
# |  -c    |  Output count of matching lines only.                                      |
# |  -l    |  Output matching files only.                                               |
# |  -n    |  Precede each matching line with a line number.                            |
# |  -b    |  A historical curiosity: precede each matching line with a block number.   |
# |  -h    |  Output matching lines without preceding them by file names.               |
# |  -s    |  Suppress error messages about nonexistent or unreadable files.            |
# |  -x    |                                                                            |
# |  -f    |  file: Take regexes from a file.                                           |
# |  -o    |  Output the matched parts of a matching line.                              |
# +--------+----------------------------------------------------------------------------+

Example 2: what can I do with grep command that is useful

15 Practical Grep Command Examples In Linux / UNIX

Tags:

Misc Example