I have the following file:
2
1
4
3
2
1
I want the output like this (unique lines that don't have any duplicates and preserve order):
4
3
I tried sort file.txt | uniq -u it works, but output is sorted:
3
4
I tried awk '!x[$0]++' file.txt it keeps order, but it prints all values once:
2
1
4
3
A couple ideas to choose from:
a) read the input file twice:
b) read the input file once:
Both of these generate: