Standard input (code 0) standard output (code 1) standard error output (code 2)
REDIRECT standard output to a file
Find/etc-name FileA >list equivalent to Find/etc-name FileA 1>list, the default > is the standard output, can write can not write, the following example is the same
redirect standard errors to a file
Find/etc-name FileA 2>list
REDIRECT standard output and standard error of a string of commands to a different file
Cat/etc/crontab/etc/filenotexist 1>stdout.txt 2>stderr.txt
REDIRECT standard output and standard errors of a sequence of commands to the same file
Cat/etc/crontab/etc/filenotexist 1>stdout.txt 2>stderr.txt
REDIRECT standard output and standard errors to the same file
Cat/etc/crontab/etc/filenotexist St.txt 2>&1
Cat/etc/crontab/etc/filenotexist &> St.txt
cat/etc/crontab/etc/filenotexist >st.txt 2>st.txt( so write is not allowed!!!) )
Standard input < and <<
< delegate reads from other files
Cat >testfile < ~/.BASHRC this statement, Cat > Testfile is a new file testfile, and waits for standard input, if it's just cat >testfile, Then after entering this command, the console will wait for keyboard input and use Ctrl+d to end the input after the input is finished. This saves the content you just entered into the testfile. The addition of < ~/.BASHRC represents the standard input to a file, and the result is the equivalent of copying a. bashrc file.
Cat >testfile << "EOF"
The function of << is equivalent to defining an end symbol, and when we enter EOF and enter it, the input ends and the content is saved to testfile.
linux-standard input Standard output