#!/bin/csh

# 86 - a c-shell script (version  8 Nov 07)
# kill any command containing $1 

# RM_CMD - command to be used for removing files and directories
if (-e /usr/bin/rm) then
   set RM_CMD = /usr/bin/rm
else
   if (-e /bin/rm) then
      set RM_CMD = /bin/rm
   else
      set RM_CMD = rm
   endif
endif

# Creat a list of jobid's matching $1
ps -u `whoami` | grep $1 | cut -c1-6 | tr -d " " > /tmp/86_$$

# kill any job matching $1 except this script
foreach JOBID (`cat /tmp/86_$$`)
  if ($JOBID != $$) kill -9 $JOBID
end

$RM_CMD /tmp/86_$$
