Closed nkrabben closed 7 years ago
LGTM - looks very useful.
Our specific use case was comparing two disc images of an audio CD.
cmp -l path/to/disk1 path/to/disk2 | wc -l
gave us the number of bytes that were different between the images.
wc -c path/to/disk1
gave us the total bytes.
Dividing the two gave us the error rate to see if it was in the error bound of a CD drive.
If this fuller use case fits into the site, I'd be happy to add it, but I'm not sure if it's too specific.
I think the specific one would work, too! Knowing whether something was in the error bound of a CD drive sounds really helpful.
If I could figure out how to pipe each of these values into a math function...
Right now the process is 2 sepearate bash commands and then using a calculator.
This is really nested, but I think it would work. Can you try it out on your test case?
echo "$(cmp -l path/to/disk1 path/to/disk2 | wc -l | tail -n 1)/$(wc -c path/to/disk1 | cut -d' ' -f4)" | bc -l
It works, but I'm not sure what the tail -n 1 is for. It worked without it.
I'm cooking up a pull request for the end of the day. Let me know if tail -n 1
is required or not
Good catch; I was getting another line of output, but it's on stderr
so you don't need tail -n 1
.
Really handy when trying to compare two files byte-by-byte