In Linux systems, you can use the -l option (lowercase L) of the grep command to display only the file names that contain the search pattern. This option causes grep to output only the file names after finding matching lines, rather than the default line content.
For example, if you want to search for all file names containing the word "example" in the current directory, you can use the following command:
bashgrep -l "example" *
This command checks all files in the current directory. For each file, grep verifies whether it contains the word "example". If it does, it outputs the file name.
Additionally, if you want to search recursively in all subdirectories and display only file names, you can add the -R option (for recursive search):
bashgrep -Rl "example" .
Here, . represents the current directory. This command searches for files containing "example" in the current directory and all its subdirectories, listing the paths of these files.
This method is highly useful, especially when searching for specific content across a large number of files, as it enables you to quickly identify files containing that content.