任何人都知道为什么BSD md5程序会以这种格式产生哈希输出...
MD5 (checksum.md5) = 9eb7a54d24dbf6a2eb9f7ce7a1853cd0
...虽然GNU md5sum会产生更明智的格式?
9eb7a54d24dbf6a2eb9f7ce7a1853cd0 checksum.md5
据我所知,md5sum格式更容易解析并且更有意义。您如何用md5进行
md5sum -check
? -p,-q,-r,-t,-x选项是什么意思? man md5
对这些选项什么也没说! :| 最佳答案
我想是历史原因。同时,-q禁止输出“MD5(...)=”,因此md5 -q checksum.md5给出
9eb7a54d24dbf6a2eb9f7ce7a1853cd0
This is implied if md5 is not given any arguments and it reads from stdin.Unfortunately md5sum in this case leaves "-" behind the checksum ("9eb7a54d24dbf6a2eb9f7ce7a1853cd0 -"),so if you're looking for some generic function to return the checksum, here is what might help:
checksum() { (md5sum <"$1"; test $? = 127 && md5 <"$1") | cut -d' ' -f1 } checksum /etc/hosts
FreeBSD's man page says about the arguments
-p Echo stdin to stdout and append the checksum to stdout.-q Quiet mode ‐ only the checksum is printed out. Overrides the -r option. -r Reverses the format of the output. This helps with visual diffs. Does nothing when combined with the -ptx options. -t Run a built‐in time trial. -x Run a built‐in test script.