Awk replace a column with its hash value

前端 未结 5 1734
你的背包
你的背包 2020-12-06 18:10

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.

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 18:38

    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 
    

提交回复
热议问题