bash - 从标准输入解码多个 base64 字符串

标签 bash macos

我有一个包含多个 base64 编码字符串的文件,这些字符串由换行符分隔:

Y2F0Cg==
ZG9nCg==
ZmlzaAo=

当我执行时:cat b64s.txt | base64 -D 我希望看到:

cat
dog
fish

但我只看到:

cat

为从标准输入中读取的每一行执行 base64 -D 的简单方法是什么?

最佳答案

while read line; do base64 -D <<< "$line"; done < b64s.txt

就其值(value)而言,在我的带有 GNU coreutils 8.28 的 Linux 系统上,解码标志是 -d 并且它会自动解码具有多个字符串的文件:

$ base64 -d b64s.txt
cat
dog
fish

关于bash - 从标准输入解码多个 base64 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52728656/

相关文章:

mysql - 暂时退出MySQL命令行到shell(bash)

linux - 从 Linux 中的所有文件名中删除括号

css - QMessageBoxes 在 OSX 中有非常奇怪的行为

macos - 如何防止 macOS 自动将 NSVisualEffectView 插入 NSScrollView

java - Mac L&F 问题 : Differing behavior of JTextField. requestFocus()

linux - 在 Linux 中使用 ssh 在本地服务器上执行远程脚本

linux - BASH while 循环和 qt-faststart

linux - 如何使用find和exec执行多条命令

objective-c - NSEvent charactersIgnoringModifiers随机抛出 "TSMProcessRawKeyCode failed"异常

macos - URLForUbiquityContainerIdentifier (iCloud) 的路径不正确