Ответ 1
По умолчанию grep не будет игнорировать несуществующие или нечитаемые файлы. Для этого вам необходимо предоставить опцию -s
или --no-messages
. Цитирование из man grep
:
-s, --no-messages Suppress error messages about nonexistent or unreadable files. Portability note: unlike GNU grep, 7th Edition Unix grep did not conform to POSIX, because it lacked -q and its -s option behaved like GNU grep -q option. USG-style grep also lacked -q but its -s option behaved like GNU grep. Portable shell scripts should avoid both -q and -s and should redirect standard and error output to /dev/null instead. (-s is specified by POSIX.)