Assuming to be in present working directory,i think this should help you.
it will search for all files name heapdump,sed will remove the last file,and awk will generate the rm command and ultimately piping to shell.
Solution:
find heapdump* |sed '$d'|awk '{print "rm -f "$1}'|sh
Steps:
Created four files heapdump1,heapdump2,heapdump3,heapdump4
robot$:ls -ltr
-rw-r--r-- 1 robot mqm 0 Nov 5 2008 heapdump1
-rw-r--r-- 1 robot mqm 0 Nov 5 2008 heapdump2
-rw-r--r-- 1 robot mqm 0 Nov 5 2008 heapdump3
-rw-r--r-- 1 robot mqm 0 Nov 5 2008 heapdump4
robot$:find heapdump*
heapdump1
heapdump2
heapdump3
heapdump4
robot$:find heapdump* |sed '$d'
heapdump1
heapdump2
heapdump3
(Excluded the last file heapdump4)
robot$:find heapdump* |sed '$d'|awk '{print "rm -f "$1}'
rm -f heapdump1
rm -f heapdump2
rm -f heapdump3
& finally
robot$:find heapdump* |sed '$d'|awk '{print "rm -f "$1}'|sh
will remove all files except heapdump4 !
Hope this is helps