bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

exit status in man page


From: Brent Barker
Subject: exit status in man page
Date: Thu, 29 Mar 2007 23:45:52 -0400

my man page (1) for "grep" states:

      Normally, exit status is 0 if selected lines are found and 1 otherwise.
      But the exit status is 2 if an error occurred, unless the -q or --quiet
      or --silent option is used and a selected line is found.


I'm using grep in a script, found here:

#!/bin/bash
if echo "$1" | grep /
then
 echo "returned 1"
else
 echo "returned 0"
fi

It seems that grep returns 1 if it finds the pattern, 0 if it does
not. This seems to be contrary to what is said in the man page. The
behavior is the same if I add the -q option.

Please let me know if I am interpreting the man page incorrectly, or
if I just found a bug in the grep man page. Thanks!

Brent Barker




reply via email to

[Prev in Thread] Current Thread [Next in Thread]