Article Directory
1. understanding input and output system
Input and output of understanding
shell program instructions ------> ------- calculation result produced cpu> character device
input instructions in a program shell, cpu to the computation results generated, and then sent to the character the device display. as the picture shows:
注意:在内存中运行文件的速度要快于硬盘;如图所示:
2. Management of input and output symbols
2.1 format command
1. The output redirection (>) | > | # Redirect correct output |
---|---|---|
2> | # Redirect error output | |
&> | # Redirect all output | |
2> &1 | # 2 will be converted to number 1 | |
echo "string"> filename | # Specify the output to a filename | |
2. Append (>>) | >> | # Append the correct output to a file last |
3. The pipe (|) | | | Enter a command output as a command to the # |
4. Input redirection (<) | < | # Input redirection |
tr 'a-z' A-Z '<westos | # Lowercase content file input into uppercase | |
tr 'A-Z' 'a-z' <westos | Uppercase content # input file to lowercase | |
cat > westos <<EOF —hello world! hello world! —EOF | # Formatted input contents to a file, note ①EOF can be replaced with other strings ② modify the password command needs to be repeated twice |
2.2 Note:
1. The output redirection
(1) covering the source file content will be redirected;
(2) must be done for experiments in the student user output redirection; the root are correct output;
2. pipe :
(1) allows only the pipe correct input;
(2) will turn through an input pipe, and these outputs into the input will be processed second order;
(3) if necessary to save the contents of the output, the required copy output command using a tee (tee commands are not displayed in the intermediate file; TEE displays the file contents in the final surface);
3. input redirection
(. 1) Touch westos.sh # .sh generated file, the file containing the desired command;
(2) SH westos.sh command execution file in #
Result1 output redirection (>, 2>, &>)
Result2 output redirection (>>, 2 >>, & >>)
Result 3 pipe symbol (|)
Result4.1 input redirection (<)
Result4.2 input redirection (<<)
3. Other commands related to the
Features | command | Note |
---|---|---|
1. Find (find) | find path -name "character" | # Find the name of the "" document |
find path -type [f / d] | # Lookup by type | |
-size + 1M find path | # Greater than 1M | |
find the path -size -1M | # Less than 1M | |
find path -maxdepth 1 -size + 1M | # 1M is greater than the current directory | |
find path -maxdepth 2 -size + 1M | # Current directory and subdirectory greater than 1M | |
2. Statistical information file (wc) | wc filename | # Statistics file information |
wc -c filename | # Of bytes, three bytes of a character | |
wc -m filename | # Number of characters (each line has a line break) | |
wc -w filename | # Number of words, words | |
wc -l filename | #Number of lines |