Data redisin the demo file aaa:
million:relive:2270371,18,1
million:relive:user:49976159,27:8,340|2018-01-26 20:25:00
million:relive:stage:22,6,1
As a result, an additional column is added based on the thrid part of the key redis:
uid,million:relive:2270371,18,1
user,million:relive:user:49976159,27:8,340
stage,million:relive:stage:22,6,1
I can generate the first column using:
awk -F":" '{print $3}' aaa | awk '{if($0 ~ /^[0-9,]+?$/) print "uid"; else print $0}'
And the second part:
awk -F"|" '{print $1}' aaa
How to combine two parts and can they be made in one sentence?
source
share