awk 用它的散列值替换一列 [英] Awk replace a column with its hash value

查看:21
本文介绍了awk 用它的散列值替换一列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何用 awk 或 sed 中的哈希值(如 MD5)替换列?

How can I replace a column with its hash value (like MD5) in awk or sed?

原始文件非常大,所以我需要这个才能真正高效.

The original file is super huge, so I need this to be really efficient.

推荐答案

我复制粘贴了 larsks 的回复,但我添加了关闭行,以避免出现本文中指出的问题:gawk/awk:管道日期到 getline *有时*不起作用

I copy pasted larsks's response, but I have added the close line, to avoid the problem indicated in this post: gawk / awk: piping date to getline *sometimes* won't work

awk '{
    tmp="echo " $2 " | openssl md5 | cut -f2 -d" ""
tmp | getline cksum
close(tmp)
$2=cksum
print
}' < sample 

这篇关于awk 用它的散列值替换一列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆