Example 8: UNIX command to display files names which contain given word Another useful grep command-line option is “grep -l” which displays only the file names which match the given pattern. Below command will only display file names that have ERROR?
$ grep -l ERROR *.log
grep -l ‘main’ *.java will list the names of all Java files in the current directory whose contents mention `main’.
Also, find command in UNIX can be used in place of grep in many places. (View Highlight)