EXIT STATUS
The grep utility exits with one of the following values:
0 One or more lines were selected.
1 No lines were selected.
>1 An error occurred.
However, if the -q or --quiet or --silent option is used and a line is
selected, the exit status is 0 even if an error occurred. Other grep
implementations may exit with status greater than 2 on error.
并且,根据实现:
Normally, exit status is 0 if matches were found, and 1 if
no matches were found. (The -v option inverts the sense
of the exit status.)
man grep
帮助:此外,对于GNU Grep:
并且,根据实现:
要测试自己,请将以下内容放入脚本并运行它。