Computing.Net > Forums > Unix > Confirm before delete.

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Confirm before delete.

Reply to Message Icon

Original Message
Name: kayarsenal
Date: September 4, 2006 at 00:56:12 Pacific
Subject: Confirm before delete.
OS: XP
CPU/Ram: Intel/1GB
Manufacturer/Model: HP
Comment:

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


Report Offensive Message For Removal


Response Number 1
Name: kayarsenal
Date: September 4, 2006 at 01:39:25 Pacific
Reply: (edit)

Instead of performing the rm -f $f operation, I want to first verify if indeed the $f is in the present in the path of files to archive.

Kayzone


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History




Data Recovery Software