cannot get the logic

there is a folder with files having two extensions . eg: A.dat and A.cv ,B.dat & B.cv etc . i want to delete files like X.cv , Y.cv because X.dat and Y.dat is not there . tell me a script for this .

Perhaps this.

for file in /dir/to/search/*.cv
do
  name=${file%.cv}.dat
  if [[ ! -f ${name} ]] ; then
    /bin/rm $file
  fi;
done

Try

for file in *.cv
do
  if [ ! -f $(basename $file .cv).dat ]; then
    rm $file
  fi
done

can u please explain the if condition that u guys have written