I have two different regular files: myscript2 and myscript3 with word 'dash' inside. I want to grep them, but because of '-r' addition to grep I got hidden files as well. I tried to use 'grep -v' after pipe to get rid of hidden files. I failed. Why? What to do to solve my problem?

$ ls myscript2 myscript3 $ cat myscript2 dash $ grep -r -l 'dash' | grep -v '^.*' 
2

1 Answer

Try --exclude:

grep -R --exclude='.*' <pattern> <dir> 
2