Reputation: 21
This is my code from previous posts, but it's not working with other delimited files.
Can you please help me in modifying this below script for any other delimited files?
awk '{
tmp="echo " $2 " | openssl md5 | cut -f2 -d\" \""
tmp | getline cksum
$2=cksum
print
}' < sample
Upvotes: 0
Views: 102
Reputation: 4786
You need to add 2 things to your awk
script:
The -F
parameter which you can set your input delimiter by, and set it to pipe (|)
the -v OPS
parameter which set the output delimiter from the default space to your desired one (e.g pipe)
Try this code:
awk -F '|' -v OFS='|' '{
tmp="echo " $2 " | openssl md5 | cut -f2 -d\" \""
tmp | getline cksum
$2=cksum
print
}' < sample
Upvotes: 1