Compare data in 2 files and delete if file exist

Hi there,

I have written a script called "compare" (see below) to make comparison between 2 files namely test_put.log and Output_A0.log

#!/bin/ksh

while read file
do
found="no"
while read line
do
echo $line | grep $file > /dev/null
if [ $? -eq 0 ]
then
echo $file found
found="yes"
break
fi
done < test_put.log
if [ $found = "no" ]
then
echo $file not found
fi
done < Output_A0.log

I have managed to extract the output as follows:

root@mapserv12 #./compare
A0567 found
A0678 found
A0789 found

Can someone give me some clues on how can I delete the files which are found? I really welcome ideas n suggestions. U may even change/ edit my script. Really need some guidance on this. Many Thanks.

Lweegp

I am not sure my understanding of your requirement is correct. If you simply wants to delete the files that are found then just use rm command. I still not sure whether it solves your requirement or not.

#!/bin/ksh

while read file
do
found="no"
while read line
do
echo $line | grep $file > /dev/null
if [ $? -eq 0 ]
then
echo $file found
found="yes"
rm $file
break
fi
done < test_put.log
if [ $found = "no" ]
then
echo $file not found
fi
done < Output_A0.log

Cheers
Narayana Gupta

hi Nara,

I'll try and let u know. thanks.

hi nara,

it works fine now. many thanks.