HOW TO CHECK ONLY .C FILES EXISTS OR NOT IN A FOLDER using IF in C shell script?

Hi friends..
I hav a problem....
I dont know how to check .c files exists r not in a folder using IF in C shell script
actually i tried like this
if(=~ *.c)
even though some .c files or there in the current folder..it is not entering int o the if control statement...

Its sooooooooo urgent..can anyone help plzzzzzzzzzzzz

if ( -e *.c ) then
echo "Found .c files"
else
echo ".c files not found"
endif

Thanks for ur kind reply friend...I tried now but it is giving error that confusion(ambuious)in *.c........
plz give me if anyother ways plzzzzzzzzzzzzzzzzzzzz

Try this:

set FIND = `find . -name "*.c" -print`
if ("$FIND" != "") then
   echo "Found files"
else
   echo "No file found"
endif

Thanks for ur kind reply expert...I tried this ..but it is always entering into if condition only,eventhough files r not there....
anyother idea plz give me friend................

find usually requires the wildcard to be escaped since it will assume it's part of the string you're looking for. Try this revision:

set FIND = `find . -name \*.c -print`
if ("$FIND" != "") then
   echo "Found files"
else
   echo "No file found"
endif

Friend ..i am sorry to say that...Again it is entering into if condition whether files r there r not(always)....
anyother idea..plz reply me......

ce9888's syntax should also work.

@p.hemadrireddy: can u pl conform once more?

is possible, pl post sample file names.

-anchal

i tried once friend evnethen ..it is always entering into if condition .............plz help meeeeeeeeeeeeeee

I tried anachal friend ..but no syntax errors..but it is always entering into if condition...

pl post whtever u have written.
again if possible, sample file name ( u want to be found )
OS flavor?

Hi, hope this helps. Please post output of this:

ls *.c && echo "Files found"

From here we can create a more flexible/complete code

hi friends ..plz help me its soooooooooo urgent

Hmmm try this

set FIND = `find ./ -name \*.c`

if ("$FIND" != "") then
   echo "Found files"
else
   echo "No file found"
endif

Use a shell that is designed for scripting:

#!/bin/sh
is_file()
{
  for file
  do
     [ -f "$1" ] && return
  done
  false
}

if is_file *.c
then
  echo YES
else
  echo NO
fi

Top Ten Reasons not to use the C shell
Csh problems
Csh Programming Considered Harmful

[quote=cfajohnson;302285088]
Use a shell that is designed for scripting:

#!/bin/sh
is_file()
{
  for file
  do
     [ -f "$1" ] && return
  done
  false
}

if is_file *.c
then
  echo YES
else
  echo NO
fi

Thank u very much for ur kind reply expert.. .......it is working under bourn shell but i wanted this same thing i nC SHELL SCRIPT...since i am new to this unix,,, icould not ble to do..plz helpp meeeeeee

If you're new to UNIX, start by doing things the right way. The C shell is not used for serious scripting; it has too many limitations, and it will be difficult to find good help because most scripters do not use it.

thanks for ur nice suggition..but i am working in a company guru...
this problem i am facing here... thats y i need it urgerntly.... plzzzzzzzzzzzzzzzz....