Since .pyc files are in binary format, you may attempt to either compare their md5sum outputs, or use cmp command to do binary diff. However, using these tools will not for .pyc files as is, because .pyc files contain extra metadata in them, which may be different even when the byte code itself is identical.
More specifically, the first 4 bytes of a .pyc file store a "magic" number which identifies the version of Python used to compile .pyc file. The next 4 bytes contain the timestamp of the Python source file.
Therefore, what you can do is to ignore the first 8 bytes of .pyc files, and compare the rest of the files. This can be achieved by the following command.
Note that this command works for bash shell.
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.