>_ IzzyLab

Topic breakdown

Removing duplicates while preserving the order of first appearance is a task where sort -u doesn't fit, because it also reorders the lines. In awk you keep an associative counter array whose key is the whole line ($0): on the first appearance the counter is still zero (false), on repeats it's already positive (true). Logically negating this counter yields the condition "print only the first occurrence"; the default action (print) outputs the surviving lines.

What's checked

  1. /root/uniq.txt holds the unique lines in order of first appearance

What it looks like