Shell logical partition, pipes, input and output labels, redirection operation (IV)

. Using a combination of commands - to separate multiple commands
separated by sequential 1.
● Use good points
- Command 1; 2 command; Command 3
- sequentially performed, only has no logical relationship
Shell logical partition, pipes, input and output labels, redirection operation (IV)

2. Logical "and" partition
● Use &&
- Command 1 Command 2 && && command .... 3
- logical relationship "And" (and), all of the desired commands may be successfully performed
- if they fail, the subsequent command is not executed
Shell logical partition, pipes, input and output labels, redirection operation (IV)

3. The logical "or" spacer
● Use ||
- || command command. 1 2 3 ... || command
- logical relationship "or" (or), a command is successfully meets any desired
- just in front of the command fails when, subsequent commands will be executed
Shell logical partition, pipes, input and output labels, redirection operation (IV)

Examples of applications
for the case of pre-order failed to set additional terms
Shell logical partition, pipes, input and output labels, redirection operation (IV)

4. The determination operation
● combinatorial logical partition
- Command 1 Command 2 || command && 3
- 1 When the command is executed successfully things, will continue to execute the command 2 (skip command 3)
- when a command fails, the command will continue to 3 (ignore command 2)
Shell logical partition, pipes, input and output labels, redirection operation (IV)
Shell logical partition, pipes, input and output labels, redirection operation (IV)

Second, the role of the pipeline
● screen output of the command to make the command end treatment
- Command 1 | command 2 | 3 ... command
- the command to follow-up the text to be able to handle correctly, otherwise no objection

Third, the use of a combination of command - marked input and output
Everything is a file
● Linux basic idea
- a regular file, directory, keyboard, mouse ... all in the form of documents
- To access the hardware device, you must find the corresponding device file

I / O switching device
● standard input: receiving data from a user input device
● standard output: report from this device to the user's normal command output
● standard error: This device reported in the error information

Types of Device file File Description No. Default Device
Standard Input /dev/stdin 0 keyboard
Standard output /dev/stdout 1 monitor
Standard error output /dev/stderr 2 monitor

stdout and stderr
● execution results for the command
- run successfully, the screen information is reported to stdout equipment
- fail, the screen information is reported to stderr device
Shell logical partition, pipes, input and output labels, redirection operation (IV)

Fourth, what is redirected
● I re-enacted direction command / O devices
- NA default keyboard, monitor
- switch to the specified text file

Type redirection
● The I / O direction and the class discrimination
Shell logical partition, pipes, input and output labels, redirection operation (IV)

Redirect input
● keyboard input -> File Input
For instance, when applicable mail command to send email -
Shell logical partition, pipes, input and output labels, redirection operation (IV)

Redirect input
● output to a display -> output to a file
when, for example, you need to save the output of a command given result -
Shell logical partition, pipes, input and output labels, redirection operation (IV)

Mixing redirection
● normal, error output, respectively / combined redirection
- for example, need to distinguish between command output, and outputs the information and or
Shell logical partition, pipes, input and output labels, redirection operation (IV)

Guess you like

Origin blog.51cto.com/14449563/2425042