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
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
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
Summary: Hi, I have to compare 2 files using shell script. I need to take the each entry/line from the first file and compare it with 2nd file whether that entry exists in second file or not. If found...ok..el...
Summary: I realy don't check if file1 or file2 exist, in this case they will always be there. My only concern is that file file1 does not overlay file2 if it's older. ...