Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need help with tcsh shell script

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

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

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.


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

BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!

Boston Linux & Unix /