How can I force grep to only return files and ignore directories? How can I force grep to only return files and ignore directories? unix unix

How can I force grep to only return files and ignore directories?


The find command?

find /bin -name bibtex -type f

Looks for a file name "bibtex" of type "f", which is a regular file.


locate --basename '\bibtex' --limit 1

Eliminates the need for grep and head, but still doesn't solve the issue of whether the result is a directory.

Why don't you do:

type -P bibtex

which will look in the PATH for a program by that name?


I don't understand exactly so maybe my solution is wrong: why don't you use which? Or bibtex isn't in PATH?