search first occurence of a file...

Hi,

I want to search for a file based on its extension. I only want to know the first occurence of the file. How do i do this?

EX: CD with 500 files. 450 of them are say “*.doc” files. I want to check if there are any doc files on CD. I do not want to search the entire CD for it.

In general, i am not bothered about how many files are present. I only want to know if it is present or not by seaching all the directories on the CD.

I tried the ‘find’ command but then it would search all the instances of the file. if there are 1000 files that are of type *.doc, then it will take a long time for me to knw that.

Thanks for your info.

qnxdevelop,

I’m assuming your wanting to do this from a shell script since you mentioned using the find command.

If you just want to know if a file is there or not, you can use find to do it. The following worked for me:

find . -name “*.doc” -abort

This tells find to abort as soon as it finds a match and return a non-zero exit status. You can check the exit status by doing a ‘$?’ command.

Tim

Thanks for the reply Tim.
I found out this solution after a while later. I had missed out to read the ‘find’ command options.

Regards.
qnxdevelop