[6180] in Athena Bugs

home help back first fref pref prev next nref lref last post

vax 7.1H: grep

daemon@ATHENA.MIT.EDU (Bruce R Lewis)
Mon Oct 8 14:45:52 1990

To: bugs@ATHENA.MIT.EDU
Date: Mon, 08 Oct 90 14:45:38 EDT
From: Bruce R Lewis <brlewis@ATHENA.MIT.EDU>

System name:		prep-8
Type and version:	CVAXSTAR 7.1H (4 update(s) to same version)
Display type:		SM

What were you trying to do?
	In a sh script:
	if [ `foo | grep -c bar baz` -eq 1 ]; then ...

What's wrong:
	grep prints nothing if no matches are found, causing the
	error:
	test: too many arguments

What should have happened:
	It should print a count of matching lines, even if that count
	is 0.  Alternatively, the man page should be changed to
	reflect actual behavior.

Please describe any relevant documentation references:

	From the man page:

	     -c   Only a count of matching lines is printed.

Workaround:

	if [ 0`foo | grep -c bar baz` -eq 1 ]; then ...


home help back first fref pref prev next nref lref last post