1847136 Members
7176 Online
110263 Solutions
New Discussion

Re: diff comand

 
Manuales
Super Advisor

diff comand

Hi all !!!
is correct this code?
i mean, i am not sure in the code of diff command into the "if"

if [ `diff ${b}_base.log ${b}_m.log` ]
then
mailx -s "Hi - `date "+%Y%m%d"` " $correos < ${ruta_monitor}/${b}_m.log
mv ${b}_m.log ${b}_base.log
fi
5 REPLIES 5
Manuales
Super Advisor

Re: diff comand

i forgot tell that once i run the shell i get this:


$ ./uno.sh
./uno.sh[106]: <: unknown test operator
$
Manuales
Super Advisor

Re: diff comand

i am using ksh
Manuales
Super Advisor

Re: diff comand

i have the answer:

WRONG:
if [ `diff ${b}_base.log ${b}_m.log` ]

GOOD AND WORKING:
if diff ${b}_base.log ${b}_m.log >/dev/null
then
-----
-----
----
fi

THANKS ANYWAY
I SAW THAT IN:
http://www.felixgers.de/teaching/shells/exercise_shells.html

Manuales
Super Advisor

Re: diff comand

Have a nice afternoon
Dennis Handly
Acclaimed Contributor

Re: diff comand

>GOOD AND WORKING:
>if diff ${b}_base.log ${b}_m.log >/dev/null
then

You can also snag the status:
diff ${b}_base.log ${b}_m.log > TMP
if [ $? -eq -0 ]; then
echo "files match"
else
echo "files differ:"
cat TMP
fi