TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
del script problems
I've got two problems with my delete (move) script, any ideas?:
1) in the process of removing the -r flags, it removes an "r" from the
filename of any file with a "-" in the name. Is there an alternative to
`echo $FLAGS |grep - |grep r` that will only pass $FLAG is it starts
with a dash and has an r?
2) If there is already a directory /home/delete/username/directory when I
try to use this script on directory, then I get "connot overwrite
directory" -- I added the -f command, but it doesn't help. Is there a way
to have it overwrite the directory and just add the files to the
directory?
Thanks,
Ben
Ben Luey
lueyb@carleton.edu
ICQ: 19144397
In politics, you get what you pay for, and vice versa. -- Scott Ostler
#!/bin/sh
for FLAGS in $*
do
FLAGS=`echo $FLAGS |sed -e "s/--/dumbgrep5664/"`
DASH=`echo $FLAGS |grep dumbgrep`
if [ ! -z $DASH ]; then
if [ $FLAGS != dumbgrep5664recursive ]; then
FLAGS=`echo $FLAGS |sed -e "s/dumbgrep5664/--/"`
NEWFLAGS="$NEWFLAGS $FLAGS"
fi
else
RECURE1=`echo $FLAGS |grep - |grep r`
RECURE2=`echo $FLAGS |grep - |grep R`
if [ ! -z $RECURE1 ]; then
NEWFLAGS="$NEWFLAGS `echo $FLAGS |sed -e "s/r//"`"
elif [ ! -z $RECURE2 ]; then
NEWFLAGS="$NEWFLAGS `echo $FLAGS |sed -e "s/R//"`"
else
NEWFLAGS="$NEWFLAGS $FLAGS"
fi
fi
done
LOGTEMP=$LOGNAME
if [ $HOME = /root ]; then
LOGNAME=root
fi
if [ -d /home/delete/$LOGNAME ]; then
#echo "mv -f $NEWFLAGS /home/delete/$LOGNAME " |sed -e "s/ - //"
`echo "mv -f $NEWFLAGS /home/delete/$LOGNAME " |sed -e "s/ - //"`
else
mkdir /home/delete/$LOGNAME
`echo "mv -f $NEWFLAGS /home/delete/$LOGNAME" |sed -e "s/ - //"`
#echo "mv -f $NEWFLAGS /home/delete/$LOGNAME" |sed -e "s/ - //"
fi
LOGNAME=$LOGTEMP