summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-01-02 11:35:02 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2012-01-02 11:37:59 -0800
commitfaf6ea13b3281a2004f5bfd1487708d1ba50a6c5 (patch)
treee3c89b2e21e5f34c885cd903da0ed04ad596f3fe /doc
parent4c6a1dcd647b208a59e3b23ad0aaf0a25397f6ad (diff)
downloadgrep-faf6ea13b3281a2004f5bfd1487708d1ba50a6c5.tar.gz
grep: -r with no args now searches "."
This is a patch I've been meaning to put in for years. When I added support for "grep -r", I forgot to have "grep -r PAT" search the working directory by default, instead of searching standard input (which makes no sense, even if stdin is a directory). This is not an upward compatible change, since "grep -r PAT <file" will no longer search standard input, but that's OK; nobody should be using "grep -r" that way anyway. * NEWS: Document this. * doc/grep.texi (File and Directory Selection, grep Programs, Usage): Likewise. * src/main.c (usage): Likewise. (grepdir): If DIR is null, search the working directory, but do not prepend "./" to the file names. (main): If recursing and no operands are given, search ".". * tests/Makefile.am (TESTS): Add r-dot. * tests/r-dot: New file.
Diffstat (limited to 'doc')
-rw-r--r--doc/grep.texi13
1 files changed, 6 insertions, 7 deletions
diff --git a/doc/grep.texi b/doc/grep.texi
index 98890958..537237f6 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -669,7 +669,7 @@ Search only files whose base name matches @var{glob}
@opindex --recursive
@cindex recursive search
@cindex searching directory trees
-For each directory mentioned on the command line,
+For each directory operand,
read and process all files in that directory, recursively.
This is the same as the @samp{--directories=recurse} option.
@@ -1010,10 +1010,12 @@ instead of strict equality with@ 2.
@cindex variants of @command{gerp}
@command{grep} searches the named input files
-(or standard input if no files are named,
-or the file name @file{-} is given)
for lines containing a match to the given pattern.
By default, @command{grep} prints the matching lines.
+A file named @file{-} stands for standard input.
+If no input is specified, a recursive @command{grep}
+searches the working directory @file{.}, and a
+nonrecursive @command{grep} searches standard input.
There are four major variants of @command{grep},
controlled by the following options.
@@ -1492,14 +1494,11 @@ find /home/gigi -name '*.c' -print0 | xargs -0r grep -H 'hello'
This differs from the command:
@example
-grep -rH 'hello' *.c
+grep -H 'hello' *.c
@end example
which merely looks for @samp{hello} in all files in the current
directory whose names end in @samp{.c}.
-Here the @option{-r} is
-probably unnecessary, as recursion occurs only in the unlikely event
-that one of @samp{.c} files is a directory.
The @samp{find ...} command line above is more similar to the command:
@example