【发布时间】:2013-12-07 05:14:34
【问题描述】:
如果可能,请提供帮助。 我想重构文件try.txt
try.txt 包含:
uid: random1
sn: 8
uid: random2
sn:: SGVsbG8sIFdvcmxkIQo=
到这里:
random1 8
random2 Hello, World!
问题出在 Base64 中。解码它的最佳和可能的方法是什么?
1) 通过 try.txt 逐行搜索并在匹配的字符串上解码
这可能与 awk 有关还是这是一厢情愿?
这不起作用 -> cat try.txt | awk '{if ($1 == "sn::") base64 -d $2'
2) 逐行搜索 sn.txt 并解码匹配的字符串
path=/dev/shm
uidf=$path/uid.txt
snf=$path/sn.txt
ff=$path/ff.txt
通过 $snf 搜索不同 Base64 编码文本的一些代码
你能帮忙吗?
2a)
猫尝试.txt | grep -v dn:| awk '/uid/ {print $2}' > $uidf
猫尝试.txt | grep -v dn:| awk '/sn/ {print $2}' > $snf
这里有一些代码来搜索base64编码的字符串并对其进行解码
paste $uidf $snf | awk '{print $1,$2}' > $ff
2b) 猫尝试.txt | grep -v dn:| awk '{打印}'
case "$string" in
"sn::" ) base64 -d $string;;
esac
【问题讨论】:
标签: bash shell awk base64 decode