Created
          March 12, 2021 17:33 
        
      - 
      
 - 
        
Save jeffmikels/a170e57c59576e945242745c8cb2cc7d to your computer and use it in GitHub Desktop.  
Revisions
- 
        
jeffmikels revised this gist
Mar 12, 2021 . No changes.There are no files selected for viewing
 - 
        
jeffmikels created this gist
Mar 12, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #!/usr/bin/env python3 # usage: # hex.py file1 file2 # cat file1 | hex.py import os, sys if len(sys.argv) > 1: for fn in sys.argv[1:]: print(fn) with open(fn, 'rb') as f: print(f.read().hex(' ', 1)) exit() hasmore = True while hasmore: # os.read returns a bytes object # sys.stdin returns a str object # read one byte from file descriptor 0 (stdin) b = os.read(0,1) if b == b'': print('') exit() print(b.hex(), end=' ')