How to compare binary files to check if they are the same?

前端 未结 14 710
傲寒
傲寒 2020-12-07 09:25

What is the easiest way (using a graphical tool or command line on Ubuntu Linux) to know if two binary files are the same or not (except for the time stamps)? I do not need

14条回答
  •  长情又很酷
    2020-12-07 10:05

    My favourite ones using xxd hex-dumper from the vim package :

    1) using vimdiff (part of vim)

    #!/bin/bash
    FILE1="$1"
    FILE2="$2"
    vimdiff <( xxd "$FILE1" ) <( xxd "$FILE2" )
    

    2) using diff

    #!/bin/bash
    FILE1=$1
    FILE2=$2
    diff -W 140 -y <( xxd $FILE1 ) <( xxd $FILE2 ) | colordiff | less -R -p '  \|  '
    

提交回复
热议问题