1. Display Normal string:
"It is a test"
The double quotes here are completely omitted, and the following commands are identical to the previous instance:
It is a test
2. Show escape characters
"\" It is a test\ ""
The result will be:
"It is a test"
Similarly, double quotes can also be omitted
3. Display variables
The read command reads a row from the standard input and assigns the value of each field in the input row to the shell variable
#!/bin/sh"$name It is a test"
The above code is saved as test.sh,name to receive the standard input variables, the result will be:
[~]# sh test. #标准输入Itis#输出
4. Show line breaks
-"ok! \ n "#-E open Escape " it it a test "
Output Result:
OK! It it a test
5. Show No Line break
#!/bin/sh-"ok! \c "#-E turn on escape \c No Line break " It is a test "
Output Result:
OK! Itis a test
6. Show results directed to file
"It is a test"> myfile
7. Output strings As-is, without escaping or taking variables (in single quotes)
' $name \ '
Output Result:
$name \ "
8. Show command Execution results
' Date '
Note: the use of anti-quotes ' instead of single quotes is used here .
The result will show the current date
Thu::
Shell script programming related 3