Awk replace a column with its hash value

前端 未结 5 1727
你的背包
你的背包 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:49

    You can also do that with perl :

    echo "aze qsd wxc" | perl -MDigest::MD5 -ne 'print "$1 ".Digest::MD5::md5_hex($2)." $3" if /([^ ]+) ([^ ]+) ([^ ]+)/' 
    aze 511e33b4b0fe4bf75aa3bbac63311e5a wxc
    

    If you want to obfuscate large amount of data it might be faster than sed and awk which need to fork a md5sum process for each lines.

提交回复
热议问题