判断两个文件是否相同

一、md5sum

Usage: md5sum [OPTION]... [FILE]...
With no FILE, or when FILE is -, read standard input.

  -b, --binary         read in binary mode
  -c, --check          read MD5 sums from the FILEs and check them
      --tag            create a BSD-style checksum
  -t, --text           read in text mode (default)
  Note: There is no difference between binary and text mode option on GNU system.

The following four options are useful only when verifying checksums:
      --quiet          don't print OK for each successfully verified file
      --status         don't output anything, status code shows success
      --strict         exit non-zero for improperly formatted checksum lines
  -w, --warn           warn about improperly formatted checksum lines

      --help     display this help and exit
      --version  output version information and exit

The sums are computed as described in RFC 1321.  When checking, the input
should be a former output of this program.  The default mode is to print
a line with checksum, a character indicating input mode ('*' for binary,
space for text), and name for each FILE.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'md5sum invocation'
# 生成文件的md5sum值,通过比较两个文件的md5sum值判断两个文件是否一样
md5sum mm10.fa > mm10.fa.md5
cat mm10.fa.md5
5cd1eb06fa018a77633bc42932f20b45  mm10.fa

md5sum chromFa.tar.gz > chromFa.tar.gz.md5
cat chromFa.tar.gz.md5 
cebdcdd7c2238f13ea261e3131b10b60  chromFa.tar.gz

# 很明显,两者不一样的。

二、我也不知道这是啥命令,但是一行就够了

cmp --silent mm10.fa chromFa.tar.gz && echo 'same' || echo 'different'
different
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • “喝”,砰的一声,酒杯碰撞的声音在这寂寥的大街上显得格外空旷。酒花飞溅,酒水入肚,这最后一杯酒也喝完了。 “两位老...
    叶初_阅读 456评论 4 6
  • 今天,在院子里又见到了一位不差钱儿的老人在垃圾桶扒拉垃圾。旁边过来阻止的光鲜体面的儿女满脸尴尬。心戚戚焉,当岁月洗...
    简斋茶悦阅读 82评论 0 0
  • 所有裸K线技术分析,重要的参考是道氏理论,所以,在进行k线技术分析时,同样有三个逻辑基础作为前提条件。下面详解每个...
    seekfor_6e86阅读 412评论 0 0
  • 在币圈,经过了2017年的牛市,享受过财富极速增长之后,整个人变得懒惰,不愿意安心工作,也想不通为啥仍要工作。即便...
    欣悦之心阅读 168评论 0 1