I do not know if I expressed myself well in the title, but please correct me if I am wrong.
Here I have a beginner problem:
I have a file with multiple lines of code, and I can number lines of code with nl command, now I want to number the lines but i want to stream the output into the same file.
So that when I open my file I will have lines numbered
For example I tried doing it this way: nl myfile.txt > myfile.txt
And then I tried sending it into a different file( nl myfile.txt > secondfile.txt) and saw that worked, so I do not understand why I cant output nl into the same file.
I also tried piping nl into the echo command like this: echo > myfile.txt | nl myfile.txt
Can someone please explain me why this doesnt't work, I am still relatively a begginer.
Thank You in advance,
Lukas Unix
Here I have a beginner problem:
I have a file with multiple lines of code, and I can number lines of code with nl command, now I want to number the lines but i want to stream the output into the same file.
So that when I open my file I will have lines numbered
For example I tried doing it this way: nl myfile.txt > myfile.txt
And then I tried sending it into a different file( nl myfile.txt > secondfile.txt) and saw that worked, so I do not understand why I cant output nl into the same file.
I also tried piping nl into the echo command like this: echo > myfile.txt | nl myfile.txt
Can someone please explain me why this doesnt't work, I am still relatively a begginer.
Thank You in advance,
Lukas Unix