bug-grep
[Top][All Lists]
Advanced

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

empty pattern: info clarification?


From: Voelker, Bernhard
Subject: empty pattern: info clarification?
Date: Tue, 3 Jan 2012 12:18:38 +0100

If grep is called with an empty expression, then that pattern
matches any string:

$ seq 2 5 | grep -n ''
1:2
2:3
3:4
4:5

Is this a bug, a feature or required by some standard?
I can't find a word about empty patterns in the texinfo manual.

However, provided this is not a bug, here is a patch
to document it.

Have a nice day,
Berny


>From e206f304caf05541f5d30f5bca78893f1383d60a Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <address@hidden>
Date: Tue, 3 Jan 2012 11:59:46 +0100
Subject: [PATCH] doc: document empty expressions

* doc/grep.texi: Discuss behaviour when using an empty expression,
e.g. `grep -n -e '' file`, which matches any string.
---
 doc/grep.texi |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 doc/grep.texi

diff --git a/doc/grep.texi b/doc/grep.texi
old mode 100644
new mode 100755
index 537237f..6557990
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -1162,6 +1162,14 @@ The preceding item is matched at least @var{n} times, 
but not more than

 @end table

+The empty expression matches any string, e.g. the following
+command will output all lines of the input file, preceded by
+a line number:
+
address@hidden
+grep -n -e '' main.c
address@hidden example
+
 Two regular expressions may be concatenated;
 the resulting regular expression
 matches any string formed by concatenating two substrings
--
1.7.5.1




reply via email to

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