To find all files containing specific text (string) on Linux, you can use the grep command with the -r (recursive) option. The grep command searches through the file, looking for matches to the pattern specified. Here is an example command:
grep -r "search_string" /path/to/search/
Replace search_string with the text you want to search for, and /path/to/search/ with the directory you want to search in. The grep command will search for all occurrences of search_string in all files within the directory and its subdirectories.
You can also use the --include and --exclude options to specify which files to include or exclude from the search. Here is an example command that includes only files with a .txt extension:
grep -r "search_string" --include "*.txt" /path/to/search/
This command will search for search_string only in files with a .txt extension in the specified directory and its subdirectories.
Note that the grep command is case-sensitive by default. To perform a case-insensitive search, use the -i option:
grep -ri "search_string" /path/to/search/
This command will search for search_string in a case-insensitive manner in the specified directory and its subdirectories.
Comments (0)