Skip to content

.tip

· one of the small things

awk '!seen[$0]++' dedupes without sorting

sort -u changes the order of the input. This keeps the first copy of each line, in the order the lines arrived.

cat urls.txt | awk '!seen[$0]++'

The first time a line shows up, seen[$0]++ is zero, so ! makes it true and awk prints the line. Every time after that it's at least one, and nothing gets printed.

shell