Hi,
am i understanding something wrong, or is this a feature:
When i do a "grep -v" on a file that contains only one line, and this
line contains the pattern
i'm looking for, then grep returns 1, not 0 as it should when it matches
a pattern:
# echo line1 > file
# grep line1 file; echo $?
line1
0
BUT:
# grep -v line1 file; echo $?
1
When i add lines which are not matched by the expression, the return
code is zero:
# echo line2 >> file
# grep -v line1 file; echo $?
line2
0
It seems that -v implicitely alters (inverts) the expression, not the
the output.
At least i would expect fgrep to behave the way i want, because it does
a string match instead of
a pattern match. However, it behaves the same.
In any case, the man page is wrong. It says that the return code is zero
if "any matches are found",
which is the case regardless whether the -v switch is set or not (from
my understanding).
Felix.