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

# Bash 的 base32 命令

base32 [OPTION]... [FILE]...

!subtitle:功能

进行 BASE32 编码或解码。

!subtitle:类型

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

!subtitle:参数

  • OPTION 选项:

    • -d, --decode - 解码;不带此选项则为编码

    • -i, --ignore-garbage - 解码时忽略无效字符

    • -w, --wrap=COLS - 编码输出时一行的字符数;默认为 76,设为 0 则不换行

    • --help - 显示帮助

    • --version - 显示版本

  • FILE - 文件列表

# 示例

$ man base32 > 1.txt
$ cat 1.txt
BASE32(1)                        User Commands                       BASE32(1)

NAME
       base32 - base32 encode/decode data and print to standard output

SYNOPSIS
       base32 [OPTION]... [FILE]
...
$ base32 1.txt > 2.txt      # 编码
$ cat 2.txt
IJAVGRJTGIUDCKJAEAQCAIBAEAQCAIBAEAQCAIBAEAQCAIBAEAQCAVLTMVZCAQ3PNVWWC3TEOMQC
AIBAEAQCAIBAEAQCAIBAEAQCAIBAEAQCAICCIFJUKMZSFAYSSCQKJZAU2RIKEAQCAIBAEAQGEYLT
MUZTEIBNEBRGC43FGMZCAZLOMNXWIZJPMRSWG33EMUQGIYLUMEQGC3TEEBYHE2LOOQQHI3ZAON2G
C3TEMFZGIIDPOV2HA5LUBIFFGWKOJ5IFGSKTBIQCAIBAEAQCAYTBONSTGMRALNHVAVCJJ5HF2LRO
...
$ base32 -d 2.txt           # 解码
BASE32(1)                        User Commands                       BASE32(1)

NAME
       base32 - base32 encode/decode data and print to standard output

SYNOPSIS
       base32 [OPTION]... [FILE]
...

# 相关命令

命令 说明
base64 进行 BASE64 编码或解码
basenc 进行 BASE2 BASE16 BASE32 BASE64 编码或解码

# 推荐阅读

# 手册

BASE32(1)                        User Commands                       BASE32(1)

NAME
       base32 - base32 encode/decode data and print to standard output

SYNOPSIS
       base32 [OPTION]... [FILE]

DESCRIPTION
       Base32 encode or decode FILE, or standard input, to standard output.

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

       Mandatory  arguments  to  long  options are mandatory for short options
       too.

       -d, --decode
              decode data

       -i, --ignore-garbage
              when decoding, ignore non-alphabet characters

       -w, --wrap=COLS
              wrap encoded lines after COLS character (default 76).  Use 0  to
              disable line wrapping

       --help display this help and exit

       --version
              output version information and exit

       The  data are encoded as described for the base32 alphabet in RFC 4648.
       When decoding, the input may contain newlines in addition to the  bytes
       of  the formal base32 alphabet.  Use --ignore-garbage to attempt to re‐
       cover from any other non-alphabet bytes in the encoded stream.

AUTHOR
       Written by Simon Josefsson.

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
       basenc(1)

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

GNU coreutils 9.4                 April 2024                         BASE32(1)
本文 更新于: 2025-11-27 09:38:13 创建于: 2025-11-27 09:38:13