I. Io Devices
Io is the source and destination of the index data, which are called standard input, standard output, and standard error output.
Programs do not have to worry about device issues, such as files, terminals, and tape drives.
By default, the system reads standard input, writes standard output, and passes errors to standard output. By default, standard input, output, and errors are all terminals.
We can see from the following:
$ Cat
Input testing # user input
Input testing # screen output
Second testing # user input
Second testing # screen output
When logging on to Linux, the terminal is set as a standard input, output, or error device by default.
2. redirection and Pipelines
Redirection:
Change the default standard input, output, and error terminal device.
Use "<" to change the default input: Program <file. You can change the standard input of program to file.
Use ">" to change the default output: CAT file. You can change the standard output of the terminal to file.
">" Is special. It is an append output.
Example: CAT> File
The terminal input is appended to the end of the file. If the file does not exist, the file is automatically created.
MPs queue:
You can connect more than two programs in progress.
Example: TR-d '/R' <file.txt | sort> file2.txt
Delete the line breaks in file.txt and then sort them. And save the result as a file2.txt input file.
3. Access shell script Parameters
Shell parameters refer to shell script command line parameters. In Shell functions, they are also parameters of Shell functions. Each parameter is named by an integer.
When there are more than 9 of them, use {} to enclose them. Example: $ {10}
For example, write a simple shell and return the terminal with the current connection similar to the condition name.
$ Cat who. Sh
#/Bin/sh
Who-A | grep $1
$ Chmod x + who. Sh
./Who. Sh tty
Returns the connection information with the terminal Name TTY.
Iv. Script tracking and execution
When writing complex scripts, tracking the script execution process will help to detect script errors and improve writing efficiency.
Set-X indicates that tracking is enabled.
Set + X indicates that the trail is stopped.