bash awk 中的 Base64 数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27323531/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 11:56:51 来源:igfitidea点击:
Base64 data in awk
提问by user3447705
I have file and process with awk tool.
我有 awk 工具的文件和进程。
awk -F "|" '{print "|" "|" "|" }' animals.csv | grep cats >> data.txt
How can i make $3 to encode base64 format?
我怎样才能赚 3 美元来编码 base64 格式?
Thank you.
谢谢你。
回答by Gilles Quenot
Try doing this :
尝试这样做:
awk -F "|" '
{
"echo "" | base64" | getline x
print x, , ,
}
' OFS='|' animals.csv | grep cats >> data.txt
the awk's getline
read a variable from a system command.
awkgetline
从系统命令中读取一个变量。
回答by BMW
Pure shell script.
纯shell脚本。
IFS="|"
while read A B C D E F G X
do
base64=$(echo $C|base64)
echo "$base64|$G|$A|$B"
done < animals.csv | grep cats >> data.txt