Reputation: 1
I would like to search all the files in the current directory only. I tried this
grep foo *
but I get this error
grep: bar: Is a directory
I also tried this
grep -r foo
but this is searching subdirectories as well.
Upvotes: 4
Views: 1909
Reputation: 1682
This is actually a comment, just don't have enough reputation to place it as a comment. your 1st answer is actually correct.
if bar is a directory within the same directory you want to search files and you don't like the error.
It can also be simple just to do away with error.
e.g.
grep foo * 2> /dev/null
Upvotes: 0
Reputation: 183371
Depending on your version of grep
, you may be able to write:
grep --directories=skip foo *
Upvotes: 4