Delete files using csh script

Want to write a csh scripts where I pass the extension of certain files, and the script will detete all such files.

For example, the following will delete all files with extension .xt

./clean.csh xt

I have tried the below to remove .xt files and did not work.

find -name "xt" -exec rm -f {} \;

Also I want only .xt files to be removed. For example, .txt files would not be touched.

find <directory_path> -name "$1" -exec rm -f {} \;

Path is missing in your command. Give absolute path under which you want to delete files, OR you can give dot(.) for current directory.
e.g.

find /abc/def -name "$1" -exec rm -f {} \;

OR

find . -name "$1" -exec rm -f {} \;

Oh yes, my mistake.

What the difference between these two?

find . -name "*.xt" -exec rm -f {} \;
find . -name "*.xt" -exec rm '{}' ';'

Would the following code remove .txt files as well?

find . -name "xt" -exec rm -f {} \;

-f option does force delete [otherwise it asks for delete confirmation (y/n) if file premission is not proper, say deleting a file owned by others]

Following will delete only file with exact xt name, So wildcard needed.

 
find . -name "xt" -exec rm -f {} \;

I understand now

---------- Post updated at 09:46 AM ---------- Previous update was at 07:31 AM ----------

I have this csh script and I want to check what the user input and only allow him to delete .xt and .ps files only. How can I do that please?

  alias MATH 'set \!:1 = `echo "\!:3-$" | bc -l`'

  set narg = $#argv
  while ($iarg < $narg)

    MATH iarg = $iarg + 1
    set arg = $argv[$iarg]
    set opt = `echo $arg | awk 'BEGIN {FS="="} {print $1}'`
    set par = `echo $arg | awk 'BEGIN {FS="="} {print $2}'`

    switch ($opt)
    case "-rmfiles":
        set rmext = `echo $par | awk 'BEGIN {FS="."} {print $1}'`
        set opt_rmfiles = 1
        breaksw
    default:
        set filename = `echo $arg | awk 'BEGIN {FS="."} {print $1}'`
        set filextension = `echo $arg | awk 'BEGIN {FS="."} {print $2}'`
        set fullnames_list = "$fullnames_list $arg"
        set fnames_list = "$fnames_list $filename"
        set fext_list = "$fext_list $filextension"
        MATH nf = $nf + 1
    endsw

  end   # while

  if ($opt_rmfiles == 1) then
    find . -name "*.$rmext" -exec rm -f {} \;
  endif