Linked Questions
20 questions linked to/from Use grep --exclude/--include syntax to not grep through certain files
8 votes
1 answer
981 views
How to find the files recursively having a text pattern excluding some directories and files [duplicate]
How to find the files recursively having a text pattern excluding some directories and files? Example:- $ ls bower.json bower_components configure results unit-tests so I need ...
0 votes
0 answers
147 views
Search in file names but exclude certain file extensions using grep [duplicate]
grep --exclude=\*.{mp3,jpg,pdf,png} -i "size\|log" | cut -c 32-|grep -v name1 |grep -v name2 it's not working for me i want to do something like ls -la | grep --exclude=\*.{mp3,jpg,pdf,png}...
1196 votes
15 answers
837k views
How can I exclude directories from grep -R?
I want to traverse all subdirectories, except the node_modules directory.
176 votes
14 answers
174k views
How can I search for a multiline pattern in a file?
I needed to find all the files that contained a specific string pattern. The first solution that comes to mind is using find piped with xargs grep: find . -iname '*.py' | xargs grep -e 'YOUR_PATTERN' ...
209 votes
6 answers
74k views
How to exclude certain directories/files from a Git grep search
Is there a way to exclude certain paths/directories/files when searching a Git repository using git grep? Something similar to the --exclude option in the normal grep command? I need to use git grep ...
203 votes
8 answers
394k views
How do I use grep to search the current directory for all files having the a string "hello" yet display only .h and .cc files?
How do I use grep to search the current directory for any and all files containing the string "hello" and display only .h and .cc files?
135 votes
7 answers
95k views
how do I use the grep --include option for multiple file types?
When I want to grep all the html files in some directory, I do the following grep --include="*.html" pattern -R /some/path which works well. The problem is how to grep all the html,htm,php files in ...
65 votes
5 answers
24k views
How do you exclude a specific file from ack (ack-grep)?
With the normal grep command there is an --exclude option (covered in detail here: Use grep --exclude/--include syntax to not grep through certain files) that lets you ignore specific files when you ...
31 votes
21 answers
19k views
Check if all of multiple strings or regexes exist in a file
I want to check if all of my strings exist in a text file. They could exist on the same line or on different lines. And partial matches should be OK. Like this: ... string1 ... string2 ... string3 ....
34 votes
6 answers
58k views
grep excluding file name pattern
I've read Use grep --exclude/--include syntax to not grep through certain files but in my CentOS6.4, when I do grep --exclude=*.cmd ckim * -r I see lots of grepped lines from *.cmd files. so it ...
28 votes
4 answers
62k views
How do I run programs with Strawberry Perl?
A coworker is trying to use ack (a Perl program) on his Windows machine, having tried it under Linux and decided he definitely wants to use it. He managed to get Strawberry Perl installed on his ...
1 vote
3 answers
14k views
Using grep to recursively search through subdirectories for specific keyword inside specific filename
Im trying to look for the text Elapsed time inside a specific log file names vsim.log. Im not familiar with grep, but after some googling I found that grep -r will allow me to do recursively searches ...
4 votes
4 answers
7k views
How to limit grep to only search the files that you want
We have a rather large and complex file system and I am trying to generate a list of files containing a particular text string. This should be simple, but I need to exclude the './svn' and './pdv' ...
1 vote
1 answer
882 views
Recursive grep within specific subdirectories
I wish to grep certain files that only exist below a specific subdirectory. Here, I only want .xml files if they exist below the /bar/ subdirectory: ./file0.xml ./.git/file1a.xml ./.git/bar/file1b....
0 votes
1 answer
391 views
grep -r --include not works but --exclude works
In bash, grep -r --exclude={*.c,} 'HELLO' // exclude c files grep -r --include={*.c,} 'HELLO' // just same with grep -r 'HELLO' What's the problem?