René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
Using awk to print duplicate lines of a file only once | ||
The following awk script prints only duplicated lines in a file, and these lines only once. The line 'deux' comes three times, but will only be output once.
awk 'seen[$0]++ == 1' <filename>
Sample input file:
eins deux drei quattro deux sechs drei acht huit neuf six deux
The output:
deux drei |