LINUX - How to compare the values in 2 files & exit from the script
Hi All,
I have a requirement where I need to compare 2 files & if the values in the files match, it should proceed, else exit the script without proceeding further. For e.g : Scenario 1 Quote:
Scenario 2 Quote:
Scenario 3 Quote:
Can anybody shed some light on how to accomplish this. Thanks Much Freddie |
It can be compared & matched with md5sum fileA & md5sum fileB or diff command
|
What about order of values, are both files always sorted the same way? For example, what should happen on this:
Quote:
|
Adding to Smilemukul's comment you may also want to check out the comm command in bash it has some nice switches.
|
The diff command returns zero if the files are the same, or non-zero if they differ.
You can use an if-statement, or just the following single line: Code:
diff 'File A' 'File B' || exit |
All times are GMT -5. The time now is 12:06 PM. |