Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Oct 1998 13:20:57 +0100
From:      Brian Somers <brian@Awfulhak.org>
To:        "Jason C. Wells" <jcwells@u.washington.edu>
Cc:        FreeBSD-questions <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Getting 'find' to stop finding 
Message-ID:  <199810201220.NAA08042@woof.lan.awfulhak.org>
In-Reply-To: Your message of "Mon, 19 Oct 1998 21:58:40 PDT." <Pine.BSF.4.05.9810192148250.20681-100000@s8-37-26.student.washington.edu> 

next in thread | previous in thread | raw e-mail | index | archive | help
> I am writing a little shell script. I would like 'find' to stop searching
> after it finds it's first match. I don't see any incantation in 'man find'
> that can do this.
> 
> Specifically, I am iterating on this command several-teen times and it is
> taking WAAAY too long. :)
> 
> 	find /usr/ports -name SomeInstalledPort -type d 
> 	cp -R /usr/ports/SomeInstalledPort SomeVeryCoolDir
> 
> What can I use to do the same function as 'find' that will stop searching
> after a match?

Try

  find /usr/ports -name SomeInstalledPort -type d | head -1

The ``find'' gets a SIGPIPE after the first line of output when 
`head' exits.

You may want to investigate the ``make search key=whatever'' facility 
too.

> Catchya Later,		|	UW Mechanical Engineering
> Jason Wells		|	http://weber.u.washington.edu/~jcwells/

-- 
Brian <brian@Awfulhak.org>, <brian@FreeBSD.org>, <brian@OpenBSD.org>
      <http://www.Awfulhak.org>;
Don't _EVER_ lose your sense of humour....



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810201220.NAA08042>