Output redirection
1, the standard input and output
device | Device file name | File descriptor | Types of |
keyboard | /dev/stdin | 0 | Standard Input |
monitor | /dev/stdout | 1 | Standard output |
monitor | /dev/stderr | 2 | Standard error output |
2, output redirection
Types of | symbol | effect |
Standard output redirection | Command> file | Overlaid manner, the correct output command to the specified file or device which |
Standard output redirection | Command >> file | In additional embodiment, the output of the correct command to the specified file or output device which |
Standard error output redirection | Error command 2> file | Overlaid manner, the error output command to the specified file or device which |
Standard error output redirection | Error command 2 >> file | In additional embodiment, the error output command to the specified file or device which |
Correct output and error while saving | Command> file 2 & 1 | To cover, and the right output and error are saved to a file with them |
Correct output and error while saving | Command >> file 2 & 1 | With an additional way to correct output and error are saved to a file with them |
Correct output and error while saving | Command &> file | To cover, and the right output and error are saved to a file with them |
Correct output and error while saving | Commands & file >> | With an additional way to correct output and error are saved to a file with them |
Correct output and error while saving | Command >> file 12 >> file 2 | The correct output is appended to the file 1 which, added to the output of the error which file 2 |
3, LS &> / dev / null : / dev / null is an empty directory, use this command is equivalent to the output of the results in this directory, it is equivalent to the result of the destruction of output, it does not show up
4, input redirection
Format: wc [options] [Optional: filename]
Options:
-c: count the number of bytes
-w: count the number of words
-l: count the number of rows
E.g:
wc: You can enter a carriage return after a bunch of content, you can press Ctrl + d exit, this time when the number of bytes wc command output statistics, words, and lines
format:
(1) Command <File: the file as a command input
(2) << command identifier: the identifier of the content between the input as a command
E.g:
access.log file written inside the content
wc <access.log: byte counts access.log file inside, words, and rows
wc access.log: This command is a command to keep up with similar, namely "<" symbol can be deleted when
wc << string: Enter the content until identified with the "string" end of the same content, and the number of bytes, words, and lines