I have a shell script in which I need to check whether two fields contain the same data or not. I do this a for a lot of files, and in my script the diff
command seems to be the performance bottleneck.
Here's the line:
diff -q $dst $new > /dev/null
if ($status) then ...
Could there be a faster way to compare the files, maybe a custom algorithm instead of the default diff
?
I believe cmp
will stop at the first byte difference:
cmp --silent $old $new || echo "files are different"