Following the advice under this question, I am able to recursively grep for a string string
within contents of a given directory dir
as follows
grep -r --exclude-dir='.*' string dir
However, when I apply this to the current directory, as
$ grep -r --exclude-dir='.*' string .
$
I get no results, since the --exclude-dir='.*'
option omits the current directory as hidden since it matches '.*'
.
A work-around is to change to the parent directory via cd ..
, then run the command on the appropriate child, then cd
again back into that original working directory. There must be a single-command that I can use to do this without the work-around of changing directories.
What is a single command to grep contents of the current directory, omitting contents of hidden directories?
grep
it produces:grep: warning: recursive search of stdin
– Wildcard Jun 19 '17 at 21:56