Grep Include Only *.txt File Pattern When Running Recursive Mode

To use grep to include only *.txt file patterns when running in recursive mode, you can use the -r option to specify recursive search and the --include option to specify the file pattern to include.

For example:

grep -r 'pattern' --include='*.txt' /path/to/directory

This will search for the string pattern in all *.txt files under the /path/to/directory directory, including all subdirectories.

Leave a Comment