I have a script that archive files then delete.How do Its working fine,however,before I perform the delete operation,I want to verify that indeed the FILE is in the path of folder I want to archive.
For example,I have a path /A/B I want all files in B to be archived,the scripts lists all the file then archive them. Now I want to take each file to be deleted,check if the file is in B folder really, then delete it.
Thanks
#!/bin/ksh
BIN=/interface/backup/dbmig/
age=$1
directory="$2"
[ "$directory" = "" ] && directory=.
cd "$directory" || exit 1
from=`$BIN/today -$age`
cd $BIN
for i in `cat filestoarchive.txt`
do
cd $i
done
find . -mtime 18 | grep -v '.tar$' | $BIN/dttmfilter | awk '$1<="'$from'"{ print;};' |
while read d t f
do
[ -d $f ] && continue
opt=u
[ -w $d.tar ] || opt=c
tar ${opt}f $d.tar $f && touch -r $f $d.tar && rm -f $f
done
Kayzone