Shell's instructions for echo output string. Format:
echo string
You can use echo to achieve more complex control the output format.
1. Normal Display string:
echo " It IS A Test " where the double quotes may be omitted altogether, the following command consistent with the above Example results: echo It IS A Test
2. Display the escape character
echo " \" It IS A Test \ " " The result will be: " It IS A Test " Similarly, double quotes may be omitted
3. Display Variables
The read command is read from the standard input line, and specifies the value of each field of the input line to the shell variable, similar to the input python
#!/bin/sh read name echo "$name It is a test"
Save test.sh above code, the variable name received standard input, the result will be:
[the root WWW @ ~] # SH Test. SH the OK # standard input OK It is a test # output
4. Display linefeed
echo -e " the OK \ the n-! " # - E open an escape echo " It IS the Test A " output: the OK ! It IS the Test A
The display does not wrap
! # / bin / SH echo -e " ! the OK \ c " # - E to open the escape \ c does not wrap echo " It IS the Test A " output: the OK It IS A the Test!
6. Showing results directed to a file
echo "It is a test" > myfile
7 is output as a string variable without escaping or taken (in single quotes)
echo ' $ name \ " ' output: $ name \ "
The display command execution result
echo `date`
Note: As used herein, is back quotes `instead of single quotes '.
The results will show the current date
You Jul 24 10 : 08 : 46 CST 2019