grep is always recursive
Loïc Grenié
loic.grenie at gmail.com
Sat Jan 24 16:29:22 UTC 2009
2009/1/24 Hal Burgiss <hal at burgiss.net>:
> Does anyone know of a setting anywhere in Ubuntu (8.04), that would
> cause grep to *always* behave as if it were run as 'grep -r'? My home
> system always greps recursively, which is highly annoying. I cannot
> find an environment setting or system file to explain this, yet
> grepping something simple in my home dir, as an example, returns a
> huge list of files, including files in various subdirectories. It
> makes no difference whatsoever whether grep is invoked as 'grep' or
> 'grep -r', the behavior is identical. I have other 8.04 systems that
> don't do this, so its quite curious to me. What I want is equivalent
> to:
>
> find -maxdepth 1 -exec grep -H $sometoken {} \;
>
> which is what I have to run now, if I am impatient (typically, yes),
> so as to avoid grepping through gigs of image and music files that
> live within $HOME subdirs.
>
> halb at honey:~$ grep -V
> GNU grep 2.5.3
>
> Copyright (C) 1988, 1992-2002, 2004, 2005 Free Software Foundation,
> Inc. This is free software; see the source for copying conditions.
> There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
>
> halb at honey:~$ which grep
> /bin/grep
> halb at honey:~$ alias grep
> bash: alias: grep: not found
> halb at honey:~$ set |grep GREP
> halb at honey:~$ set |grep _grep
You can try to use strace to see what happens. Something
like:
strace -o /tmp/trace bash
grep something *
<Ctrl-C> after some time
exit
Try whether sh -c 'grep something *' has the same behaviour.
In that case strace -o /tmp/trace sh -c 'grep something *'
will be the same (but easier)
Then grep execve /tmp/trace to see whether grep is called
as grep -r or not and to check which grep is executed.
Not the easiest, but worth a try if nobody else has a
better idea !
Loïc
More information about the ubuntu-users
mailing list