Skip to content

Instantly share code, notes, and snippets.

@josephwb
Created March 6, 2014 16:52
Show Gist options
  • Save josephwb/9394151 to your computer and use it in GitHub Desktop.
Save josephwb/9394151 to your computer and use it in GitHub Desktop.
Compare 2 files, byte-by-byte
#!/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"
@josephwb
Copy link
Author

josephwb commented Mar 6, 2014

Quits after first difference. No message if files are identical.
Blatantly stolen from http://stackoverflow.com/a/12900693/3389183.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment