grep without showing path/file:line grep without showing path/file:line linux linux

grep without showing path/file:line


No need to find. If you are just looking for a pattern within a specific directory, this should suffice:

grep -hn FOO /your/path/*.bar

Where -h is the parameter to hide the filename, as from man grep:

-h, --no-filename

Suppress the prefixing of file names on output. This is the default when there is only one file (or only standard input) to search.

Note that you were using

-H, --with-filename

Print the file name for each match. This is the default when there is more than one file to search.


Just replace -H with -h. Check man grep for more details on options

find . -name '*.bar' -exec grep -hn FOO {} \;


From the man page:

-h, --no-filename    Suppress the prefixing of file names on output. This is the default when there    is only one file (or only standard input) to search.