Group rows in text file and aggregate corresponding rows to column
awk, bash
Solution
command
awk -F '|' '
$1==x{
printf ",%s", $2
next
}
{
x=$1
printf "\n%s|%s", $1, $2
}
END {
printf "\n"
}' input.txt
result
John|Life,Temp,Admin
Peter|Life,Admin
Matt|Life,Admin,Temp
Problem
Group rows in text file and aggregate corresponding rows to column Existing text file ``` John|Life John|Temp John|Admin Peter|Life Peter|Admin Matt|Life Matt|Admin Matt|Temp ``` Desired output ``` John|Life,Temp,Admin Peter|Life,Admin Matt|Life,Temp,Admin ``` Thanks in advance