Linux shell redirection and shell redirection
Redirects the shell error output to the standard output to record the error information of the script.
For example:
/Root/test. sh> test. log 2> & 1
Note:
Linux first loads/etc/rc. d/rc. local and then/etc/profile
Teach linux shell to redirect a simple question: why does ls-l>/111txt>/222txt not input the results to both files?
Redirection is like this. The command result can only be output to one place. You can understand the principle.
In IO Redirection, stdout or stderr pipelines are always prepared before the command execution result is imported.
In the example you provided, first redirect to/111.txtand then to/222.txt. therefore, the MPs queue is connected to/222.txt. Stdout has only one pipe, and the input end is fixed. You just keep moving the output end. Of course, the last one prevails.
I suggest you go to Shell 13th question, which contains detailed explanations of IO Redirection.
The solution is to use the tee command:
Ls-l | tee/111.txt>/222.txt
How does linux shell redirect the echo content to a variable?
Var2 = $ (echo $ var)