|
awk is one of the best tools, if not the best, to work with tabular data.
on the other hand, powerful it is, regular expression is overly used in the wrong places.
To solve your problem with awk,
awk '{for(i=3; i<=NF; i++) if($i==$2) $i = "" } { print }' 2nd-col.txt > 2nd-cleaned.txt
suppose 2nd-col.txt is your original file and 2nd-cleaned.txt is your cleaned file.
I've uploaded a screenshot, but I'm not sure whether it shows correctly.
|
|