Brief-Wishbone9091
Member
Note that the bash shell effectively removes the redirection from the command line before argument 0 is executed. This means that in the case of this command:
Code:
echo hello > greetings.txt
the shell only counts two arguments (echo = argument 0, hello = argument 1). The redirection is removed before the argument counting takes place.
I feel it's telling before counting the number of arguments, redirection operator is ignored.
But later it says how it affects output erasing file case.
While scanning the line, the shell will see the > sign and will clear the file! Since this happens before resolving argument 0, this means that even when the command fails, the file will have been cleared!
Code:
[paul@RHELv4u3 ~]$ cat winter.txt
It is cold today!
[paul@RHELv4u3 ~]$ zcho It is cold today! > winter.txt
-bash: zcho: command not found
[paul@RHELv4u3 ~]$ cat winter.txt
[paul@RHELv4u3 ~]$
My estimate
1) > is removed.
2) Number of arguments are count. There are 2 arguments "It is cold today!" and winter.txt
3) then what? i don't know.