One thing you could do is write an 'rm' wrapper to avoid these situations in the future. Here is something to get you started:
#!/bin/ksh
OPTIONS=0
PROG='$0'
while getopts rRfie option
do
case ${option} in
r) rOPTION="-r"
((OPTIONS=OPTIONS+1));;
R) ROPTION="-R"
((OPTIONS=OPTIONS+1));;
f) fOPTION="-f"
((OPTIONS=OPTIONS+1));;
i) iOPTION="-i"
((OPTIONS=OPTIONS+1));;
e) eOPTION="-e"
((OPTIONS=OPTIONS+1));;
?) echo "Usage: rm [-r] [-R] [-f] [-i] [-e] File..."
exit 2
esac
done
shift ${OPTIONS}
if [ "${fOPTION}" = "" ]
then
PIDLIST=`fuser ${*} 2> /dev/null | tr -d 'a-z'`
for PID in ${PIDLIST}
do
if [ ${PID} -ne ${$} ]
then
echo "Removed failed. ${1} currently in use by:"
echo
ps -fp `echo ${PIDLIST} | tr ' ' ','`
exit 1
fi
done
fi
if [ "${rOPTION}" = "" ]
then
rm ${ROPTION} ${fOPTION} ${iOPTION} ${eOPTION} ${*}
else
for dir in ${*}
do
FILELIST="`ls -a ${dir}/.[!.]* 2> /dev/null` `ls ${dir}`"
for file in ${FILELIST}
do
if [ -d ${dir}/${file} ]
then
${PROG} -r ${ROPTION} ${fOPTION} ${iOPTION} ${eOPTION} ${dir}/${file}
else
${PROG} ${ROPTION} ${fOPTION} ${iOPTION} ${eOPTION} ${dir}/${file}
fi
done
done
fi
Regards,
Chuck