我有一个文本文件,每一行是一个单独的base64编码的单词。现在我想解码它。我试图使用base64命令行,但我得到的所有单词只有一行,我想每行一个。例如,我的文件是:
Y2F0Cg== ZG9nCg== aG91c2UK
字符串我想要的结果是:
dog cat house
型但我得到了:
dogcathouse
型我想xargs可以帮上忙,但我不明白。
aij0ehis1#
将base64 --decode与循环一起使用:
base64 --decode
$ while IFS= read -r line; do echo "$line" | base64 --decode; done < file cat dog house
字符串
deyfvvtc2#
这在base64 8.13中适用:
base64
base64 --decode test.txt
字符串不需要拆分文件。您使用的是哪个版本?
dly7yett3#
你可以使用Python(不需要阅读每一行):
python -m base64 -d foo.txt
csga3l584#
你可以使用bash here-document <<<来实现。
<<<
cat FILE | xargs -I{} bash -c 'base64 -d <<< {}'
klh5stk15#
您可以在每行后追加Cg==(base64编码的\n)。
Cg==
\n
sed 's/$/Cg==/' file.txt | base64 -d
5条答案
按热度按时间aij0ehis1#
将
base64 --decode
与循环一起使用:字符串
deyfvvtc2#
这在
base64
8.13中适用:字符串
不需要拆分文件。您使用的是哪个版本?
dly7yett3#
你可以使用Python(不需要阅读每一行):
字符串
csga3l584#
你可以使用bash here-document
<<<
来实现。字符串
klh5stk15#
您可以在每行后追加
Cg==
(base64编码的\n
)。字符串