Linux search for a given string in all files recursively

In this article let’s discuss about Linux search for a given string in all files recursively. Let’s go through the following methods without any delay.

Method 1:

# look for airflow Variable usage recursively in it's homepath
# include only python and sql files in the search
grep --include=\*.{py,sql} -rnw /home/airflow -e 'Variable'

# shows how to use exclude... it'll skip data or log files
grep --exclude=\*.{data,log} -rnw . -e 'Variable'

If you are facing any issues with the above approach then try the alternative that is given below. It may look similar but have a try!

Method 2 :

grep -rnw '/path/to/somewhere/' -e 'pattern'

Hope the above solution works.

Realted Posts : How to create virtual host for magento 2