And here is the ungolfed version:
awk '{ if (! visited[$0]) { print $0; visited[$0] = 1 } }'
awk '{ if (! visited[$0]) { print $0; visited[$0] = 1 } }'
'awk' is really a very beautiful little language. It's concise enough to solve many tasks in a single line, making it easy to use interactively while still being able to grow to moderately-sized scripts. It's not supposed to replace a full-blown scripting language like Python, but for processing files line-by-line it's superb.
awk '! visited[$0] { print $0; visited[$0] = 1 }'
awk '!($0 in seen); {seen[$0]}'for ex:
awk -o '{ORS = NR%2 ? " " : RS} 1'
gives (default output file is awkprof.out) {
ORS = (NR % 2 ? " " : RS)
}
1 {
print $0
}