I have logs in this format:
log1,john,time,etc log2,peter,time,etc log3,jack,time,etc log4,peter,time,etc
I want to create a list for every per
You can use awk. As a demo:
awk
awk -F, '{a1[$2]=a1[$2]" \""$0"\""; sum[$2]++} END{for (e in sum){print e"=(" "\""sum[e]"\""a1[e]")"}}' file john=("1" "log1,john,time,etc") peter=("2" "log2,peter,time,etc" "log4,peter,time,etc") jack=("1" "log3,jack,time,etc")