Unik

Python replacement for the uniq command.

#!/usr/bin/env python3
import sys
seen = set()
for line in sys.stdin:
    if line not in seen:
        seen.add(line)
        sys.stdout.write(line)

This is not equivalent to sort -u because it preserves the original order, and it’s not equivalent to uniq because it removes duplicates even when they’re not adjacent.

 

Unknown's avatar

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment