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?
perl -i -pe '$_ = "$. $_"' test.txt
... also there is a commandnl
for numbering purposes – Sundeep Jul 26 '17 at 14:09