I am looking for an awk solution which would fetch lines which are unique based on 2nd column when the 1st & 3rd and 4th columns are the same.
constraints :
- column 3 and column 4 has to be same for the rows (two consecutinve rows sorted on the 3rd column)
- if 1 is true, check if column 1 is same for those rows from step 1.
- then check if rows from step 2 have same column 2 values , if not then print out the rows (both rows) else print none of both rows.
input file :-
AB|abcd|0001|Active
AB|efgh|0001|Active
AB|efgh|0001|Closed
CD|xyz|0002|Active
CD|pqr|0002|Active
EF|xyz|0003|Active
EF|xyz|0003|Closed
output :-
AB|abcd|0001|Active
AB|efgh|0001|Active
CD|xyz|0002|Active
CD|pqr|0002|Active
tried below code but it gives me same $2 values
awk -F'|' '
BEGIN{OFS=FS}
$4 ~ /Active/ && a[$3]++ && $2 != c {
print r ORS $0
}
{r=$0; c=$2}' <(sort -k3,3 file)