Created
March 6, 2014 16:52
-
-
Save josephwb/9394151 to your computer and use it in GitHub Desktop.
Compare 2 files, byte-by-byte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## script to check if files contain identical data (by byte). stops at first difference. | |
## Usage: | |
## ./cFiles.sh file1 file2 | |
## It may be necessary to change access permission to make the script executable. Type: | |
## chmod 755 cFiles.sh | |
if [ "$#" -ne 2 ] | |
then | |
printf "Usage: \n./cFiles.sh file1 file2\n" | |
exit 1 | |
fi | |
cmp --silent $1 $2 || echo "files are different" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quits after first difference. No message if files are identical.
Blatantly stolen from http://stackoverflow.com/a/12900693/3389183.