9-Linux grep return code
Posted 番茄土豆西红柿
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了9-Linux grep return code相关的知识,希望对你有一定的参考价值。
The exit code is 1 because nothing was matched by grep.
EXIT STATUS The exit status is 0 if selected lines are found, and 1 if not found. If an error occurred the exit status is 2. (Note: POSIX error handling code should check for ‘2‘ or greater.)
The output is zero because the count of ‘Total‘ is zero. This due to the -c option:
-c, --count Suppress normal output; instead print a count of matching lines for each input file. With the -v, --invert-match option (see below), count non-matching lines. (-c is specified by POSIX.)
If you would like to force an exit code of 0, you can just append || true
to your command:
echo ‘Total‘ | grep -c No || true
以上是关于9-Linux grep return code的主要内容,如果未能解决你的问题,请参考以下文章
macos + vs code + grep 进行多文件搜索
MRTG Monitoring with ESXi Hosted Guest Return ‘interface is commented * has no ifSpeed property’(示例代
The return type is incompatible with JspSourceDependent.getDependants():JasperException问题分析与解决方法(示例代
iOS开发-27解决方式:An error was encountered while running(Domain=FBSOpenApplicationErrorDomain, Code=4)((代
TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2(代