1. Read command
The read command reads information through a keyboard or a line of text in a file and assigns a value to a variable.
1.1, read reading the keyboard data, the input of the content before the return of the data assigned to a variable:
cb@standalone14:~$ read name
Hello CB I am ubuntu. #回车
cb@standalone14:~$ echo $name
Hello CB I am ubuntu. #显示变量的值
1.2, instance shell script, save code as. sh file, change executable permissions, run See effect:
#!/bin/sh
# var test
Echo-n "The name: \c"
read name
echo-n "middle name: \c"
Read Middle
ech O-n ' Last name: \c '
read surname
Echo ' the ' $name
Echo ' middle name is ' $middle
Echo ' last Name is "$surname
2, Cat command
The cat command is used to display the contents of a file and can display 1 or more files.
The cat command is used to display the contents of a file and can display 1 or more files.
Cat myfile #显示myfile的文件内容, will display all content at once, to avoid when large files;
cat myfile1 myfile2 > Myfile3 # Redirect the contents of Myfile1 and Myfile2 to Myfile3;
Cat myfile | More #把myfile的内容传递给 command, with more commands to achieve pagination display;
3, Pipeline
Pipeline, which enables the output of one command to be passed to another command as its input. The pipeline is represented by |. General form: Command 1 | Command 2 ls-l | The output of the grep CB # ls command is piped to the grep command. In one line of commands, you can use multiple pipes, and the pipes will be executed from left to right.