Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I am comparing 2 files and if any error found i am sending message to tmpfile4 and mailing it to dba team.counter=1
exec 3< ${tmpfile}while read -u3 line
do
grep "$line" ${tmpfile3} 1>/dev/null
if [[ $? -eq 1 ]]
then
print "Warning: File $line is missing from the archived log directory !!!" >> $tmpfile4
fi(( counter += 1 ))
doneHere, If nothing is missing,
I would like to add only one line "nothing is missing" to tmpfile4. How do I do it?
If I include it inside the 'IF condition above, It will print for each line of comparison. I just want to print one line after comparison nothing is found missing.
Any help?Thanks and Regards
Sureshsureshht

This worked for me:
#!/bin/ksh
tmpfile=suresh1.data
tmpfile3=suresh2.datacounter=0
exec 3< ${tmpfile}while read -u3 line
do
grep "$line" ${tmpfile3} 1>/dev/null
if [[ $? -eq 1 ]]
then
print "Warning: File $line is missing from the archived log directory !!!" >> $tmpfile
(( counter += 1 ))
fidone
if [[ $counter = 0 ]]
then
print "nothing is missing"
fi

I can't believe I made such an rookie mistake in my solution. Severe brain cramp.
#!/bin/kshtmpfile=lemieux1.data
tmpfile3=lemieux2.datacounter=0
exec 3< ${tmpfile}while read -u3 line
do
grep "$line" ${tmpfile3} 1>/dev/null
if [[ $? -eq 1 ]]
then
print "Warning: File $line is missing from the archived log directory !!!" >> $tmpfile4
(( counter += 1 ))
fidone
if [[ $counter -eq 0 ]]
then
print "nothing is missing"
fi

If it is not working, then you have a different issue. If you create data file A and copy it to data file B, you can then run the script I gave you and compare the 2 files. It will print "nothing is missing" since the 2 files are identical. Perhap if you change:
print "nothing is missing"
to
print "nothing is missing" >>$tmpfile4You'll get the desired result.

![]() |
Different results from aw...
|
awk summing col1 for simi...
|

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