用git bash调用md5sum进行批量MD5计算

对于非常大的文件或者很重要的文件,在不稳定的网络环境下,可能文件的某些字节会损坏。此时,对文件计算MD5即可以校验其完整性。比如本次的 OpenStreetMap 导出包,我的学弟反馈通过网盘下载无法解压,并建议我增加每个文件的MD5校验。

对于文件非常多的情况,需要批量计算。最简便的方法是使用git自带的md5sum进行计算。

1. 安装git并进入bash

到 https://git-scm.com/ 下载git,并安装。

安装后,右键单击网盘下载的文件夹,选择“git bash” 进入bash:

bash
bash
可以查看 md5sum的说明

$ md5sum --help
Usage: md5sum [OPTION]... [FILE]...
Print or check MD5 (128-bit) checksums.With no FILE, or when FILE is -, read standard input.-b, --binary         read in binary mode (default unless reading tty stdin)-c, --check          read MD5 sums from the FILEs and check them--tag            create a BSD-style checksum-t, --text           read in text mode (default if reading tty stdin)-z, --zero           end each output line with NUL, not newline,and disable file name escapingThe following five options are useful only when verifying checksums:--ignore-missing  don't fail or report status for missing files--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 exitThe 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 space, a character indicating input mode ('*' for binary,
' ' for text or where binary is insignificant), and name for each FILE.Note: There is no difference between binary mode and text mode on GNU systems.GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
Full documentation <https://www.gnu.org/software/coreutils/md5sum>
or available locally via: info '(coreutils) md5sum invocation'

2. 批量计算md5

Linux常见命令 find 能够枚举文件并批量执行指令。

执行下面的指令,可以在屏幕输出各个文件的md5:

$ find ./Arch*.* -exec md5sum {} \;
d060dd81785d957ae4e2bbd4f9ebeb4e *./ArchOSManjaro.7z.001
b7326e73452d3fbbc56a889f55aa9a14 *./ArchOSManjaro.7z.002
805c9ef68887953554c6c160c2a72eeb *./ArchOSManjaro.7z.003
#...
2cc5ab567abba1d7e3a284ec5c383d84 *./ArchOSManjaro.7z.059
$

执行下面的指令,可以在文件输出各个文件的md5:

$ find ./Arch*.* -exec md5sum {} >> md5.txt \;

3.比较两个文件是否一致

我们假设本地校验结果放在check.txt,标准校验结果放在 md5.txt,则使用下面指令比较:

$ diff --help
Usage: diff [OPTION]... FILES
Compare FILES line by line.Mandatory arguments to long options are mandatory for short options too.--normal                  output a normal diff (the default)-q, --brief                   report only when files differ-s, --report-identical-files  report when two files are the same-c, -C NUM, --context[=NUM]   output NUM (default 3) lines of copied context-u, -U NUM, --unified[=NUM]   output NUM (default 3) lines of unified context-e, --ed                      output an ed script-n, --rcs                     output an RCS format diff-y, --side-by-side            output in two columns-W, --width=NUM               output at most NUM (default 130) print columns--left-column             output only the left column of common lines--suppress-common-lines   do not output common lines-p, --show-c-function         show which C function each change is in-F, --show-function-line=RE   show the most recent line matching RE--label LABEL             use LABEL instead of file name and timestamp(can be repeated)-t, --expand-tabs             expand tabs to spaces in output-T, --initial-tab             make tabs line up by prepending a tab--tabsize=NUM             tab stops every NUM (default 8) print columns--suppress-blank-empty    suppress space or tab before empty output lines-l, --paginate                pass output through 'pr' to paginate it-r, --recursive                 recursively compare any subdirectories found--no-dereference            don't follow symbolic links-N, --new-file                  treat absent files as empty--unidirectional-new-file   treat absent first files as empty--ignore-file-name-case     ignore case when comparing file names--no-ignore-file-name-case  consider case when comparing file names-x, --exclude=PAT               exclude files that match PAT-X, --exclude-from=FILE         exclude files that match any pattern in FILE-S, --starting-file=FILE        start with FILE when comparing directories--from-file=FILE1           compare FILE1 to all operands;FILE1 can be a directory--to-file=FILE2             compare all operands to FILE2;FILE2 can be a directory-i, --ignore-case               ignore case differences in file contents-E, --ignore-tab-expansion      ignore changes due to tab expansion-Z, --ignore-trailing-space     ignore white space at line end-b, --ignore-space-change       ignore changes in the amount of white space-w, --ignore-all-space          ignore all white space-B, --ignore-blank-lines        ignore changes where lines are all blank-I, --ignore-matching-lines=RE  ignore changes where all lines match RE-a, --text                      treat all files as text--strip-trailing-cr         strip trailing carriage return on input--binary                    read and write data in binary mode-D, --ifdef=NAME                output merged file with '#ifdef NAME' diffs--GTYPE-group-format=GFMT   format GTYPE input groups with GFMT--line-format=LFMT          format all input lines with LFMT--LTYPE-line-format=LFMT    format LTYPE input lines with LFMTThese format options provide fine-grained control over the outputof diff, generalizing -D/--ifdef.LTYPE is 'old', 'new', or 'unchanged'.  GTYPE is LTYPE or 'changed'.GFMT (only) may contain:%<  lines from FILE1%>  lines from FILE2%=  lines common to FILE1 and FILE2%[-][WIDTH][.[PREC]]{doxX}LETTER  printf-style spec for LETTERLETTERs are as follows for new group, lower case for old group:F  first line numberL  last line numberN  number of lines = L-F+1E  F-1M  L+1%(A=B?T:E)  if A equals B then T else ELFMT (only) may contain:%L  contents of line%l  contents of line, excluding any trailing newline%[-][WIDTH][.[PREC]]{doxX}n  printf-style spec for input line numberBoth GFMT and LFMT may contain:%%  %%c'C'  the single character C%c'\OOO'  the character with octal code OOOC    the character C (other characters represent themselves)-d, --minimal            try hard to find a smaller set of changes--horizon-lines=NUM  keep NUM lines of the common prefix and suffix--speed-large-files  assume large files and many scattered small changes--color[=WHEN]       color output; WHEN is 'never', 'always', or 'auto';plain --color means --color='auto'--palette=PALETTE    the colors to use when --color is active; PALETTE isa colon-separated list of terminfo capabilities--help               display this help and exit-v, --version            output version information and exitFILES are 'FILE1 FILE2' or 'DIR1 DIR2' or 'DIR FILE' or 'FILE DIR'.
If --from-file or --to-file is given, there are no restrictions on FILE(s).
If a FILE is '-', read standard input.
Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.Report bugs to: bug-diffutils@gnu.org
GNU diffutils home page: <https://www.gnu.org/software/diffutils/>
General help using GNU software: <https://www.gnu.org/gethelp/>

执行指令:

$ diff  check.txt  md5.txt
36c36
< 23dfa036cd5d772f01173da67ebf2634 *./ArchOSManjaro.7z.029
---
> db2ce0bc5c39fd5d8f672f478788095c *./ArchOSManjaro.7z.029

可以看到第29号文件有问题。

使用 -y 选项,可以查看完整输出(左右两列)

$ diff -y check.txt  md5.txt
..
e155774f7dd158ded02d9a9aae68f5eb *./ArchOSManjaro.7z.028        e155774f7dd158ded02d9a9aae68f5eb *./ArchOSManjaro.7z.028
23dfa036cd5d772f01173da67ebf2634 *./ArchOSManjaro.7z.029      | db2ce0bc5c39fd5d8f672f478788095c *./ArchOSManjaro.7z.029
c8c32363ebd14a7eefce1cadaaa64def *./ArchOSManjaro.7z.030        c8c32363ebd14a7eefce1cadaaa64def *./ArchOSManjaro.7z.030
...

不一致的行,会用竖线“|”标记。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/634954.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MOS管和IGBT管的定义与辨别

MOS管和IGBT管作为现代电子设备使用频率较高的新型电子器件&#xff0c;因此在电子电路中常常碰到也习以为常。可是MOS管和IGBT管由于外形及静态参数相似的很&#xff0c;有时在选择、判断、使用容易出差池。MOS管和IGBT管可靠的识别方法为选择、判断、使用扫清障碍&#xff01…

android使用相机 intent.resolveActivity returns null

问题 笔者使用java进行android开发&#xff0c;启动相机时 intent.resolveActivity returns null takePictureIntent.resolveActivity(getPackageManager()) null详细问题 笔者使用如下代码启动相机 // 启动相机SuppressLint("LongLogTag")private void dispatc…

【LGR-172-Div.4】洛谷入门赛 #19(A—H,c++详解!)

文章目录 【LGR-172-Div.4】洛谷入门赛 #19A.分饼干 I题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1 样例 #2样例输入 #2样例输出 #2 提示样例解释 1样例解释 2数据范围与约定思路: 代码 B.分饼干 II题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1 样例 #2样…

2024--Django平台开发-订单项目管理(十四)

day14 订单管理系统 1.关于登录 1.1 UI美化 页面美化&#xff0c;用BootStrap 自定义BooStrapForm类实现。 class BootStrapForm:exclude_filed_list []def __init__(self, *args, **kwargs):super().__init__(*args, **kwargs)# {title:对象,"percent":对象}fo…

电路复习总结

又到了个人最喜欢的电路复习环节&#xff0c;废话不多说一个个复习过来 1.电路基本概念 2.向量表示 现在在看美少女老师教学某一种正弦交流电的办法学的就很舒服 知道复数和极坐标还挺重要可以便于后面数值计算 2024年1月18日19:44:57 根本整理不出来什么东西i 在学习中逐…

测试 ASP.NET Core 中间件

正常情况下&#xff0c;中间件会在主程序入口统一进行实例化&#xff0c;这样如果想单独测试某一个中间件就很不方便&#xff0c;为了能测试单个中间件&#xff0c;可以使用 TestServer 单独测试。 这样便可以&#xff1a; 实例化只包含需要测试的组件的应用管道。发送自定义请…

龙芯+RT-Thread+LVGL实战笔记(30)——电子琴演奏

【写在前面】正值期末,笔者工作繁忙,因此本系列教程的更新频率有所放缓,还望订阅本专栏的朋友理解,请勿催更。笔者在此也简要声明几点: 有些硬件模块笔者并没有,如LED点阵、压力传感模块、RFID模块等,因此这些模块的相关任务暂时无法给出经过验证的代码。其实,教程进行…

排序之归并排序

在计算机科学中&#xff0c;排序是一种常见的操作。它用于将一组元素按照一定的顺序排列。归并排序是一种非常有效的排序算法&#xff0c;其时间复杂度为O(nlogn)&#xff0c;空间复杂度为O(n)。本文将详细介绍归并排序的工作原理和实现方法。 归并排序的工作原理 归并排序的…

智慧之光:ChatGPT 引领工作效率新纪元

随着科技的不断发展&#xff0c;人工智能&#xff08;AI&#xff09;已经逐渐融入我们的日常生活和工作中。其中&#xff0c;ChatGPT 作为一种先进的 AI 技术&#xff0c;正逐步改变我们的工作方式&#xff0c;提升我们的工作效率。本文灸哥将介绍如何利用ChatGPT提升工作效率&…

Pytest插件pytest-django让Django测试更高效

在Django应用开发中&#xff0c;测试是确保应用质量的关键环节。然而&#xff0c;Django自带的测试框架并非总能满足开发者的需求&#xff0c;而Pytest插件 pytest-django 则为我们提供了更为灵活、强大的测试工具。本文将深入介绍 pytest-django 插件的基本用法和实际案例&…

后面的输入框与前面的联动,输入框只能输入正数(不用正则)

概要 提示&#xff1a;这里可以描述概要 前面的输入框是发票金额&#xff0c;后面的输入框是累计发票金额&#xff08;含本次&#xff09;--含本次就代表后倾请求的接口的数据&#xff08;不是保存后返显的-因为保存后返显的是含本次&#xff09;是不含本次的所以在输入发票金…

Linux基础命令[1]-ls

文章目录 1. ls 命令说明2. ls 常用命令参数2.1 -l&#xff08;展示详细信息&#xff09;2.2 -a/-A&#xff08;展示隐藏文件&#xff09;2.3 -t/-c/-r&#xff08;展示信息排序&#xff09;2.4 -h&#xff08;展示文件大小&#xff09;2.5 -R&#xff08;递归展示&#xff09;…

iphone5s基带部分电源部分主主电源供电及

时序: 1.,基带电源的供电&#xff0c;基带电源也叫pmu。 首先时序图说电池提供供电&#xff0c;电池是J6接口&#xff0c;视频习惯把接口称之为座子。查U2_RF芯片&#xff0c;发现供电信号为PP_BATT_VCC_CONN&#xff0c;但是没查到跟电池座子有关系&#xff0c;电池座子写的是…

linux C语言socket函数recv

recv 函数是在 Linux C 语言网络编程中用于从已连接的套接字接收数据的函数。它通常与 TCP 连接一起使用&#xff0c;但也可以用于 UDP&#xff08;尽管对于 UDP&#xff0c;更常使用 recvfrom&#xff0c;因为它还可以接收发送方的地址信息&#xff09;。 函数原型 recv 函数…

SpringMVC基础知识学习笔记

Universe Infinity Inc. 目录 一、学习SpringMVC主要是学什么1、SpringMVC的基本原理2、SpringMVC学习串联 二、快速体验SpringMVC的开发1、新建项目&#xff0c;转成web项目2、引入依赖3、编写Spring的配置类4、配置web启动类&#xff0c;替代web.xml5、编写Handler&#xff…

第十二篇【传奇开心果系列】Ant Design Mobile of React开发移动应用:内置组件实现酷炫CSS 动画

Ant Design Mobile of React 开发移动应用示例博文系列 第一篇【传奇开心果系列】Ant Design Mobile of React 开发移动应用:从helloworld开始 第二篇【传奇开心果系列】Ant Design Mobile of React 开发移动应用:天气应用 第三篇【传奇开心果系列】Ant Design Mobile of Reac…

beego的模块篇 - I18n国际化

1. i18n 安装导入 安装该模块&#xff1a; go get github.com/beego/i18n 导入引用包&#xff1a; import ("github.com/beego/i18n" ) conf 目录下就有 locale_en-US.ini 和 locale_zh-CN.ini 两个本地化文件。 本地化文件的文件名和后缀是随意的&#xff0c;不…

MySQL 索引(上)

&#x1f389;欢迎您来到我的MySQL基础复习专栏 ☆* o(≧▽≦)o *☆哈喽~我是小小恶斯法克&#x1f379; ✨博客主页&#xff1a;小小恶斯法克的博客 &#x1f388;该系列文章专栏&#xff1a;重拾MySQL-进阶篇 &#x1f379;文章作者技术和水平很有限&#xff0c;如果文中出现…

libpcap简明教程

文章目录 前言tcpdump的使用libpcap API的简单使用libpcap API的进阶使用 前言 因为之前简单写过wireshark入门指北&#xff0c;所以我知道基本的抓包流程。最近尝试调用libpcap的C API接口&#xff0c;顺道整理下。 本文实验如下&#xff1a; 使用tcpdump命令抓取目标地址为…