From: Tzafrir Cohen on
On Thu, Jun 10, 2010 at 10:58:58PM +0200, Merciadri Luca wrote:
> Hi,
>
> I find `find' very inefficient when trying to find some files. I prefer
> using `ls -alR | grep stuff' The problem is that the related output does
> not give me the directory where `stuff' is found. How can I add some row
> giving this? Thanks.

Others already mentioned location. I'll just note that 'find' and 'ls
-lR' should have comparable speeds. find's output should be nicer to
parse.

A single 'find' is normally enough to cache the relevant directories.
E.g.:

real 3m48.317s
user 0m1.568s
sys 0m7.948s
tzafrir(a)sweetmorn:~$ time find /usr >/dev/null

real 0m13.977s
user 0m0.772s
sys 0m1.532s
tzafrir(a)sweetmorn:~$ time find /usr >/dev/null

real 0m0.956s
user 0m0.332s
sys 0m0.616s
tzafrir(a)sweetmorn:~$ time find /usr >/dev/null

real 0m0.968s
user 0m0.372s
sys 0m0.576s

Actually the second 'find' took way longer than I expected.

$ free
total used free shared buffers cached
Mem: 2051620 1965084 86536 0 253852 284188
-/+ buffers/cache: 1427044 624576
Swap: 2000968 118404 1882564

--
Tzafrir Cohen | tzafrir(a)jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tzafrir(a)cohens.org.il | | best
tzafrir(a)debian.org | | friend


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/20100610215821.GW16560(a)pear.tzafrir.org.il
From: Merciadri Luca on
Tzafrir Cohen wrote:
> On Thu, Jun 10, 2010 at 10:58:58PM +0200, Merciadri Luca wrote:
>
>
> Others already mentioned location. I'll just note that 'find' and 'ls
> -lR' should have comparable speeds. find's output should be nicer to
> parse.
>
> A single 'find' is normally enough to cache the relevant directories.
>
Well, you first need to do _one_ find before for both to have the same
speed. That's the problem. Locate seems to do what I want.
> E.g.:
>
> real 3m48.317s
> user 0m1.568s
> sys 0m7.948s
> tzafrir(a)sweetmorn:~$ time find /usr >/dev/null
>
> real 0m13.977s
> user 0m0.772s
> sys 0m1.532s
> tzafrir(a)sweetmorn:~$ time find /usr >/dev/null
>
> real 0m0.956s
> user 0m0.332s
> sys 0m0.616s
> tzafrir(a)sweetmorn:~$ time find /usr >/dev/null
>
> real 0m0.968s
> user 0m0.372s
> sys 0m0.576s
>
> Actually the second 'find' took way longer than I expected.
>
> $ free
> total used free shared buffers cached
> Mem: 2051620 1965084 86536 0 253852 284188
> -/+ buffers/cache: 1427044 624576
> Swap: 2000968 118404 1882564
>
Thanks.

--
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
I use PGP. If there is an incompatibility problem with your mail
client, please contact me.


There are only two tragedies in life: one is not getting what one wants,
and the other is getting it. (Oscar Wilde)

From: Tzafrir Cohen on
On Fri, Jun 11, 2010 at 12:18:58AM +0200, Merciadri Luca wrote:
> Tzafrir Cohen wrote:
> > On Thu, Jun 10, 2010 at 10:58:58PM +0200, Merciadri Luca wrote:
> >
> >
> > Others already mentioned location. I'll just note that 'find' and 'ls
> > -lR' should have comparable speeds. find's output should be nicer to
> > parse.
> >
> > A single 'find' is normally enough to cache the relevant directories.
> >
> Well, you first need to do _one_ find before for both to have the same
> speed. That's the problem. Locate seems to do what I want.

That is, unless you're not really sure the relevant sub-tree is
up-to-date and run updatedb, which is equivalent to 'find /' (with
proper excludes).

--
Tzafrir Cohen | tzafrir(a)jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tzafrir(a)cohens.org.il | | best
tzafrir(a)debian.org | | friend


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/20100610222849.GX16560(a)pear.tzafrir.org.il
From: Merciadri Luca on
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Camaleón <noelamac(a)gmail.com> writes:

> On Thu, 10 Jun 2010 22:58:58 +0200, Merciadri Luca wrote:
>
>> I find `find' very inefficient when trying to find some files.
>
> (...)
>
> I've got a "one-liner" saved:
>
> ***
> find /directory/to/find/* -type f -exec grep -H 'text' {} \;
> ***
Nice! Thanks. (Once again, I never received this message by e-mail,
even if I am a subscriber to the ML... still wondering why!)
- --
Merciadri Luca
See http://www.student.montefiore.ulg.ac.be/~merciadri/
- --

If all else fails, try the obvious.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iEYEARECAAYFAkwRZXYACgkQM0LLzLt8MhxMIACghOWE4BMkhIIZ0gbtKkttGxdW
aGgAoIWv+s2oScHpRZXX7EqApj/SQnTg
=HZNJ
-----END PGP SIGNATURE-----


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/87zkz234w9.fsf(a)merciadriluca-station.MERCIADRILUCA
From: Tom Furie on
On Thu, Jun 10, 2010 at 09:46:12PM +0000, Camaleón wrote:

> find /directory/to/find/* -type f -exec grep -H 'text' {} \;

For that application, wouldn't you be better just using grep alone?

i.e. grep -r 'text' /directory/to/find/

Cheers,
Tom

--
Raising pet electric eels is gaining a lot of current popularity.