mardi 13 janvier 2015

Why recursive grep does not work with STDOUT?


I've been long used to have some custom aliases in my Ubuntu/Mint machines, like alias grep='grep -irn --color --line-buffered'. However, I've noticed that since a while ago this stopped working for piped outputs.


Trying to debug, I've noticed the problematic option is the recursive one, and instead of grep'ping the STDOUT it searches from the current directory - recursively.


I'm currently running grep 2.16, and I've found a machine that's working as I expected running 2.10.


Example: tail -f /var/log/xxx.log | grep -irn yyy


What has been changed that -r/-d recurse makes grep search for a folder instead of following the man directory option?



-d ACTION, --directories=ACTION
If an input file is a directory, use ACTION to process it.
[...] If ACTION is recurse, read all files under each directory, recursively,
following symbolic links only if they are on the command line. This is
equivalent to the -r option.


Aucun commentaire:

Enregistrer un commentaire