Shell programming echo command usage instructions, shell programming echo command
Shell echo commands are similar to PHP echo commands and are used to output values. We can use echo to implement more complex output format control.
Show normal strings
Echo "Hello World" echo Hello World
The output results of these two sentences are: Hello World.
Show escape characters
Echo "\" Hello World \ "" echo \ "Hello World \"
The output result is "Hello World"
Show Variables
The read command reads a line from the standard input and specifies the value of each field in the input line to the shell variable.
Read nameecho "Your input is $ name"
Name receives standard input variables.
Display line feed
Echo-e "OK! \ N "#-e enable escape echo" It is a test"
Output result:
Show do not wrap
Echo-e "OK! \ C "#-e enable escape \ c do not wrap echo" It is a test"
Output result:
The display result is directed to the file.
Echo "It is a test"> myfile
Output string without escape or variable (single quotation marks)
Echo '$ name \"'
Output result: $ name \"
Display command execution results
Echo 'date'
The result shows the current date: