CSH - finding files with the same file extension

Hey,

I'm having a problem finding out if a directory holds any files with a certain file extension, for example .txt.

I have tried:

if (! -e "*.txt")

and I've tried:

set FILES=`ls *`

        echo "Found $FILES"

        foreach FILE ($FILES)
		
if($FILE == "*.txt")

And neither of these work... any ideas? Your help is much appreciated!!

Are you looking for the file names, or just want to know if there is at least one file with the .txt extension?

Maybe there's a better way, and mind you I'm using KSH, but here's what I'd do:

count=`ls /path/*.txt | grep -c txt`

I am trying to check if there is a txt file within a directory, and if ther is I need to do one thing, and if there isn't I need to do something else.

I have tried the code sample and it works I can now use the returning value within a variable and compare this in an if statement.

Thank you for your help!