I am new to learning Linux cli and I encountered an interesting problem.
I created a 1.txt file such:
1
1
2
2
3
When I use uniq 1.txt
it emits 1 2 3
. I decided to output this result to 1.txt
, so this small trick would delete all the duplicating elements in the file and save it. To do that I used this command : uniq 1.txt > 1.txt
. But in the end it shows that 1.txt
file is totally empty. Can anyone help me to understand what happened?