Computing.Net > Forums > Unix > Compare 2 files if it's same r not

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Compare 2 files if it's same r not

Reply to Message Icon

Name: kris955
Date: September 3, 2008 at 09:04:59 Pacific
OS: windows
CPU/Ram: intel
Product: dell
Comment:

Hi,
I need to compare two files using shell script.
(file1: inbound/data/lockbox &
file2:inbound/data/lockbox/archive)
If they are same it should email saying files are same and if they are not same, then Concurrent program should get kickoff.
some one please help me with this issue.
Thanks in advance,
kris



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: September 3, 2008 at 11:06:09 Pacific
Reply:

Are you asking for a Unix shell script? Your OS says Windows.


0

Response Number 2
Name: kris955
Date: September 3, 2008 at 16:15:23 Pacific
Reply:

Yes asking about Unix Shell Script.


0

Response Number 3
Name: nails
Date: September 3, 2008 at 19:13:37 Pacific
Reply:

This script assumes that your mail server is already set up. The unix cmp command sets the exit code, $?, to zero if file1 and file2 are the same. If they are different, the exit code is non-zero.


#!/bin/ksh

cmp file1 file2 > /dev/null
if [[ $? -eq 0 ]]
then # the unix here document executes mailx
mailx nails@myserver << MSG
files are the same
MSG
else
echo "execute the command"
# execute your concurrent command
fi


0

Response Number 4
Name: kris955
Date: September 5, 2008 at 13:10:15 Pacific
Reply:

Thanks a lot!! It works for me.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Compare 2 files if it's same r not

Comparing 2 files www.computing.net/answers/unix/comparing-2-files/7690.html

Compare 2 files inode modification www.computing.net/answers/unix/compare-2-files-inode-modification/5866.html

Append if it's wednesday www.computing.net/answers/unix/append-if-its-wednesday/7512.html