(B) bash basis

3: The basic features of the Bash

View (1) command history

history [options] [history command to save the file]

Options: -c: Clear History command

-w: the cache write history command history command to save the file. If you do not manually specified history commands to save the file, then save the file into the default history command ~ / .bash_history in.

 

(2) the command call history

There are several ways so if you want to use the original command history:

 use the down arrow recall previous commands.

 Use "! N" history repeats implementing Article n command.

 Use "!!" repeat the last command.

 Use "! String" repeat the last command beginning with that string.

 Use "! $" Repeat the last parameter of a command.

 

(3) Input and output redirection

Equipment Equipment Type a file name file descriptor

Keyboard / dev / stdin 0 standard input            

Display / dev / stdout 1 standard output

Display / dev / stderr 2 stderr

(1) standard output redirection

Command> file

Overlaid manner, the output of the correct command input

Or the device to which the specified file.

Command >> file

In additional embodiment, the output of the correct command input

Or the device to which the specified file.

(2) the standard error output redirection

Error command 2> file

Overlaid manner, the error output command input

Or the device to which the specified file.

Error command 2 >> file

In additional embodiment, the error output command input

Or the device to which the specified file.

(3) the correct output and error

While preserving

Command> file 2> & 1

Overlaid manner, and outputs the correct transmission errors

That are saved to a file with them.

Command >> file 2> & 1

In an additional manner, the correct output, and error output

That are saved to a file with them.

Command &> file

Overlaid manner, and outputs the correct transmission errors

That are saved to a file with them.

Commands & file >>

In an additional manner, the correct output, and error output

That are saved to a file with them.

Command >> file 12 >> file 2

The correct output is appended to the file 1, the wrong

Errors in the output 2 is added to the file.

 

4: command execution

Multi-character format command role.

; Command 1; 2 command plurality of commands executed sequentially, there is no link between the command.

&& command && command 2 1 

When properly executed command 1 ($? = 0), the command will be executed 2.

1 When the command execution is incorrect ($? ≠ 0), the command will not be executed 2.

|| 1 || command Command 2

1 When the command execution is incorrect ($? ≠ 0), the command will be executed 2.

When the command is executed correctly 1 ($? = 0), the command will not be executed 2.

 

Guess you like

Origin www.cnblogs.com/love-life-insist/p/11668751.html