I have a tab delimited file:
qrs John tuv
abcd Sam efgh
ijk Sam lmnp
abcd Sam efgh
ijk Sam lmnp
qrs John tuv
I am trying to print the line in which the second field does not match the previous line's value in the second field and to print the line in which the second field does not match the next line.
I've been playing with variations of the following but nothing is quite working like I expect:
awk -F"\t" '{
name=$3;
line=$0;
getline;
newname=$3;
newline=$0;
getline;
nextname=$3;
nextline=$0;
if (newname != name || name != nextname)print line"\n"nextline }' input.txt