I'm running the following command to add line numbers:
perl -pe '$_ = "$. $_"'
I can append the results to a file with:
cat test.txt | perl -pe '$_ = "$. $_"' >> test.txt
But if I try to replace the current contents the file ends up blank:
cat test.txt | perl -pe '$_ = "$. $_"' > test.txt
Why is this?