Problem
You want to run a command, save the output to a file – then compare the output at a later date with the file.
For example – you want to update your crontab: save a backup crontab -l > cronfile.$(date +%j), make your updates, then compare it with the backup file.
Solution
Use diff with the hypen to represent read from stdin.
This saves keeping multiple copies.
Example
crontab -l > cronfile.$(date +%j)
crontab -e # make your diffs
crontab -l | diff - cronfile.$(date +%j)
Also you can use cmp, which just reports the line number, etc
crontab -l > cronfile.$(date +%j)
crontab -e # make your diffs
crontab -l | cmp - cronfile.$(date +%j)
Reference
[tags]crontab, diff, cmp, comparing command output with file, UNIX Coding School[/tags]