I also use Ubuntu 12.04, and I get this error:
$ grep -r 'test' . > tmp.txt
grep: input file `./tmp.txt' is also the output
Because redirection will be expand first, so tmp.txt
is created in current directory before grep
is executed, leading to error occurs.
If I change tmp.txt
to other path, like /tmp/tmp.txt
, then it works normally.
My grep
version:
$ grep --version
grep (GNU grep) 2.10
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.