用 numfmt 转换人类可读的数字
把字节数变成 1G/1M,或把可读单位解析回原始数字。
运行 numfmt --to=iec 1073741824,输出 1.0G。
01命令
命令
$ numfmt --to=iec 107374182402作用说明
numfmt 是 coreutils 的辅助工具,在普通数字与 SI/IEC 单位之间转换。--to=iec 输出 1.0G 这类二进制单位,--from=si 解析 1M 这样的值,在管道中搭配 awk 可让体积列更易读。
03风险
!注意: SI(1000 进制)与 IEC(1024 进制)不同,要根据产生数字的工具选择。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- GNU coreutils: numfmt依据: Documents numfmt, which reformats numbers to or from human-readable units.
- Debian package: coreutils依据: Debian packages the GNU coreutils suite, which provides this command.
最后验证: 2026-09-20 · 分类: 开发者