Crazy Idea


how to (politely) stop a find process after the 1st match
April 26, 2007, 12:26 am
Filed under: howto

LazyWeb,

I’m on windows(cygwin); Every now and then, I run a “find” task which finds the file and then continues searching for a lot more time . I’d like it to abort after the 1st match.

eg : find . -type f – iname “foo.txt” -exec xemacs.bat {} ;

Is there a way to tell find that “hey, after you find the 1st match(a file), do the exec piece and then quit the find part of it ?

I know that I could create a .bat file that finds who its parent process is and terminates it. But is there a more nicer way ? 🙂

Thanks for any hints.

Advertisements

2 Comments so far
Leave a comment

Don’t use -exec

find . -type f -iname “foo.txt”|head -1 |xemacs.bat –

This, of course, presumes that the first foo.txt is always the right one.

Comment by Gautam Guliani

Hi Gautam,

Thanks for the tip. That works!! Now I have one more convenience batch file

BR,
~A

Comment by anjanb




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s



%d bloggers like this: