Search for a specific string pattern in files in linux
To search for a matching patter in files can be done by executing the below commands in linux
[snippet slug=720 lang=bash]
You can do pattern search based on specific file extensions. In the below example, we are trying to lookup .php and .jsp files for the pattern “Sample Pattern”
[snippet slug=grep-pattern2 lang=bash]
In a similar way, you can use the exclude parameter to exclude certain file extensions
[snippet slug=file_pattern lang=bash]
Specific directories can also be excluded
[snippet slug=grep_dir_pattern lang=bash]
Alternate method to perform the pattern search,
[snippet slug=grep_recurs lang=bash]