'How can I remove "grep: XXX: Is a directory" logs appearing when terminal is opened?
How can I remove grep: XXX: Is a directory logs appearing when terminal is opened?
Why does these logs always appear?
Last login: Fri Jan 28 14:44:36 on ttys005
grep: Applications: Is a directory
grep: Desktop: Is a directory
grep: Documents: Is a directory
grep: Downloads: Is a directory
grep: Library: Is a directory
grep: Movies: Is a directory
grep: Music: Is a directory
grep: Pictures: Is a directory
grep: Postman: Is a directory
grep: Public: Is a directory
grep: Sites: Is a directory
grep: test: Is a directory
grep: work: Is a directory
~
❯
- zsh
- macOS Big Sur 11.6.2
Solution 1:[1]
Linux man pages mention that there is a -d option along with which some action can be specified like skip, etc.
https://man7.org/linux/man-pages/man1/grep.1.html
-d ACTION, --directories=ACTION
If an input file is a directory, use ACTION to process it. By default, ACTION is read, i.e., read directories just as if they were ordinary files. If ACTION is skip, silently skip directories. If ACTION is recurse, read all files under each directory, recursively, following symbolic links only if they are on the command line. This is equivalent to the -r option.
Solution 2:[2]
grep command is designed to inspect matching in text files.
If you include directories in grep command file list, you get these errors.
If you wan to omit directories from grep text files use the following option: --directories=skip
If you wan to recurse directories from grep text files use the following option: --directories=recurse
As stated in the grep command help.
-d, --directories=ACTION how to handle directories;
ACTION is 'read', 'recurse', or 'skip'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kiner_shah |
| Solution 2 | Dudi Boy |
