国际访客建议访问 Primers 编程伙伴 国际版站点 > Bash 教程 > sum 以获得更好的体验。

# Bash 的 sum 命令

sum [OPTION]... [FILE]...

!subtitle:功能

查看文件的校验和和块数。

!subtitle:类型

可执行文件(/usr/bin/sum),属于 coreutils

!subtitle:参数

  • OPTION 选项:

    • -r - 使用 BSD 求和算法(默认);块大小为 1K

    • -s, --sysv - 使用 System V 求和算法;块大小为 512 字节

    • --help - 显示帮助

    • --version - 显示版本

  • FILE - 文件列表;如果没有这个参数或指定为 -,则读取标准输入

# 示例

$ sum 1.txt             # 使用 BSD 算法
08227     1 1.txt
$ sum -s 1.txt          # 使用 System V 算法
3977      1 1.txt

# 推荐阅读

# 手册

SUM(1)                           User Commands                          SUM(1)

NAME
       sum - checksum and count the blocks in a file

SYNOPSIS
       sum [OPTION]... [FILE]...

DESCRIPTION
       Print or check BSD (16-bit) checksums.

       With no FILE, or when FILE is -, read standard input.

       -r     use BSD sum algorithm (the default), use 1K blocks

       -s, --sysv
              use System V sum algorithm, use 512 bytes blocks

       --help display this help and exit

       --version
              output version information and exit

AUTHOR
       Written by Kayvan Aghaiepour and David MacKenzie.

REPORTING BUGS
       GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
       Report any translation bugs to <https://translationproject.org/team/>

COPYRIGHT
       Copyright  ©  2023  Free Software Foundation, Inc.  License GPLv3+: GNU
       GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
       This is free software: you are free  to  change  and  redistribute  it.
       There is NO WARRANTY, to the extent permitted by law.

SEE ALSO
       Full documentation <https://www.gnu.org/software/coreutils/sum>
       or available locally via: info '(coreutils) sum invocation'

GNU coreutils 9.4                 April 2024                            SUM(1)
本文 更新于: 2026-03-06 09:52:35 创建于: 2026-03-06 09:52:35