this is a small little script that diffs file against another folder. if there is no diff, the retrun code is zero - for success, and if there is a difference between the two files, the diff returns a 1, for unsuccessful. If you use the quiet flag the diff returns a very nice " these two files differ notice.
I guess the only problem is that i want to use the if statement, but I don't really want to print anything out on a "no diff in files" or successful. I don't really want to print the zero for success. but i cannot leave the if ; then "nothing" fi. I have to put something command like after the then. If the line is black after the "then" the program errors out. "bash if" demands a command after " then " If I just put in an echo statement, it prints our a blank line. and I do not want that either. I would like the script to do nothing on total success, and only tell me when if fails. SO I don not want the echo "$?" return the return code. actually I don't want anything there. I want the opposite of an "if success". I tried testing for a if [ ! diff original target ] but that did now work.
capser@casperhost:~$ cat /come/and/play/with_us/danny/puc_diff.sh2
#!/bin/bash
#set -x
original="/home/casper"
target="/sbcimp/dyn/data/EVT/GSD/scripts"
date=$(/bin/date +%Y%m%d)
for i in PUCZ.pl POI.pl PUConoff.pl PUCVolBands.pl PUCC.pl
do
if diff -q $original/$i $target/$i
then
echo "$?"
fi
done
exit 0
capser@casperhost:~$ /come/and/play/with_us/danny/puc_diff.sh2
0
0
0
0
Files /home/casper/PUCC.pl and /where/on/a/road/to/nowhere/PUCC.pl differ
capser@casperhost:~$
~ ~