Need help with tcsh shell script

Scott Ehrlich se at panix.com
Mon May 28 09:44:31 EDT 2001


Hello to all:

Five or more years ago, the following piece of shell code worked fine. Now
that I have a need to use it again, OS upgrades/enhancements has broken it
and I am hoping you can help fix it.

The code is:

if [ `diff /home/scott/old-file /home/scott/new-file | wc -c` -ne 0]


What the script itself does is preceding the above line, it obtains a text
file from another location.   The above line compares the newly acquired
file with a version already on the system.  If they are the same, the
script should die.  If there is a difference, the subsequent code
processes the new file.

Now that I rejuvenated the script, the above gave an error with the
brackets '[]' so I replaced them with parentheses '()' to result in:

if ( `diff /home/scott/old-file /home/scott/new-file | wc -c` -ne 0)

which tcsh liked more.  But now it complains about wc, especially -ne (not
equal to) 0.   So, I obtained the latest GNU textutils and that seems to
have fixed the wc problem.

I recall having gone through many rounds of support (possibly on this list
in years' past) until somebody came up with the above if line which worked
beautifully.

Here I come again.   If you can get the above if/diff/wc line to work it
would be greatly appreciated.

If you feel it easier in a shell different than tcsh, please give that a
shot.

The ultimate goal is to successfully compare the two text files under tcsh
(if at all possible), proceed if the files differ, or die if the files are
the same.

Thanks for any help.

Scott


-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).



More information about the Discuss mailing list