1

When running

grep 'string' *

I'm getting the following messages:

grep: some-directory: Is a directory
grep: other-directory: Is a directory

How to suppress those messages?

BlueSkies
  • 2,035
  • 7
  • 17
  • 42
  • Does this answer your question? [How to use grep on all files non-recursively in a directory?](https://askubuntu.com/questions/777379/how-to-use-grep-on-all-files-non-recursively-in-a-directory) –  Jul 24 '21 at 08:40

2 Answers2

5

-s, --no-messages: Suppress error messages about nonexistent or unreadable files.

grep -s 'string' *
Wayne Vosberg
  • 748
  • 3
  • 5
0

There are at least two ways to suppress error messages ("Is a directory"):

  1. grep -s 'string' *

  2. grep 'string' * 2> /dev/null

BlueSkies
  • 2,035
  • 7
  • 17
  • 42