Technical question about scripts

Curt Grimley Curt_Grimley at usa.net
Thu Apr 3 05:24:16 PST 2003


Mr. Chen's solution is a good one, and you might simplify it like this:

# Where a, b and c are the config files:
md5before=`cat a b c | md5`
vi a b c
md5after=`cat a b c | md5`
if [ $md5before = $md5after ]
then
   exit # no changes made
fi

------------
Curt Grimley

-----Original Message-----
From: owner-freebsd-questions at freebsd.org
[mailto:owner-freebsd-questions at freebsd.org]On Behalf Of Jonathan Chen
Sent: Wednesday, April 02, 2003 9:09 PM
To: Dragoncrest
Cc: freebsd-questions at freebsd.org
Subject: Re: Technical question about scripts


On Wed, Apr 02, 2003 at 08:57:48PM -0500, Dragoncrest wrote:
> 	I've got a bit of a technical question about doing scripts.  I've
> 	created a script that I use for expediting changes to one of my servers
to
> save me a large number or repetitive steps that I have to do.  My question
> is this though.  Using either Pico or VI I need to be able to have the
> script know if I've saved/changed the file or if I just exited out without
> saving my changes.  Cause if I exited out without saving changes, I want
it
> to abort the rest of the script, but if I changed any one of my config
> files, I want it to then complete the rest of the script.  Anyone know how
> to do this via a shell script?

Keep a md5 checksum of the old file. If the checksum differs on the
file after edit, it must have changed.
--
Jonathan Chen <jonc at chen.org.nz>
----------------------------------------------------------------------
                                             When all else fails, RTFM
_______________________________________________
freebsd-questions at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"



More information about the freebsd-questions mailing list