I'm kind of confused on the sequence Linux handles Redirection Operator.
I have in my home just one file:
andy$: ls demo.mp4
Now, if I send the
ls output to a file, I should see only
demo.mp4 in the file because there is nothing in the directory other than this file:
andy$: ls > myfile
But I actually noticed
myfile contains itself!
andy$ cat myfile demo.mp4 myfile <-- ???
So this means that
ls gets executed AFTER the creation of
- List directory content with
- Write the content (now
So in case I need to exclude self I think I should:
ls | grep -v "myfile" > myfile
So first, am I right?
If so, WHY!? Where can I find more infos on this?