Issue
How can I print only those lines that appear exactly once in a file? E.g., given this file:
mountain
forest
mountain
eagle
The output would be this, because the line mountain
appears twice:
forest
eagle
- The lines can be sorted, if necessary.
Solution
Using awk:
awk '{!seen[$0]++};END{for(i in seen) if(seen[i]==1)print i}' file
eagle
forest
Answered By - anubhava Answer Checked By - Cary Denson (WPSolving Admin)