Tee Cat >> Test << delimiter use file descriptors for redirection (0 1 2) redirect standard output and standard error to separate file/dev/null redirect two file descriptors, exec n>&m
Tee
To redirect output to files and screens at the same time:
Date | Tee now
Cat >> test << delimiter
Use a custom delimiter to create a document
Delimiter is a delimiter, customizable, and we're using append redirection
The above command means:
The current document, as input to cat, redirects the output (append) of cat to test
The current document refers to this section:
using file descriptors for redirection (0 1 2)
is actually redirecting standard input, standard output, and standard errors to the specified file
EXEC 1>out
After this command is executed, the output is redirected to the out file, and there is no more output on the screen
To redirect the output back to the terminal, execute:
EXEC 1>/dev/tty
The most we use is the normal input and output redirection
cmd n>file
cmd n>>file
Change the value of N to redirect the output information of the cmd command or error message to the file
CMD 0<file
The command is to redirect input to file redirection standard output and standard error to a separate file
CMD 1> file1 2> file2
The above command redirects the output of the cmd command to the FILE1, redirecting the standard error to the File2
We can also redirect standard output and standard errors to the same file, as follows:
CMD 1> file1 2>&
/dev/null
Explain this file, he is more special, if we use the following command to redirect the output of the cat command to a file, the contents of the file will become empty: cat/dev/null > File
REDIRECT two file descriptors, exec n>&m
For example, we now associate a file descriptor with a file:
EXEC 4>file
And then we'll execute the order.
EXEC 5>&4
After this command is executed, file descriptors 4 and 5 all point to file file , that is, 5 is 4 copy
Then we execute LS 1 >&5, and LS 1>&4 is the same effect
LS output will be redirected to file file