Use of the echo command
Echo command
Function: display characters
Syntax: echo [- neE] [string]
Description: echo sends the input string to standard output. The output strings are separated by blank characters, followed by a line break
Number
Several output modes:
Double quotation mark output:
Single quotation mark output is a silly symbol, which is the original string output.
Reverse single quotation mark command reference
One command calls the execution result of the second command, using ``or $()
Echo "$VAR_NAME": variables are replaced, double quotes are weakly referenced
Echo'$VAR_NAME': variables will not be replaced, strongly referenced
$echo-e "Enter the file name:\ c"
Echo needs to use the-e parameter to print escape characters.
Echo command options:
-n is not in the last automatic line wrapping of the character
-e if the following characters appear in the string, they will be specially treated instead of being output as normal text:
\ a sound of warning
\ b Backspace key
\ c finally, no newline symbol is added.
\ nWrap and the cursor moves to the beginning of the line
\ r move the cursor to the beginning of the line, but do not wrap
\ t insert tab
\ insert\ character
\ 0nnn inserts ASCII characters represented by nnn (octal)
Echo-e "\ 033 [43 × 31mred color\ 033 [0m"
\ xHH inserts ASCII characters represented by HH (hexadecimal)
Edit the path where the file's color is located
Command line extended, enclosed collection
Command line extension: $() or ``
Print the output of one command to the parameters of another command
$echo "Thissystem'snameis$ (hostname)"
$echo "I am `whoami`"
Parenthesis extension: {}
Print a simplified form of a duplicate string
$echofile {1JI 3JI 5}
$rm-ffile {1JI 3JI 5}
The echo display in the shell script is displayed with color:
The echo display content in the shell script is displayed with color, and the echo display with color. You need to use the parameter-e.
The format is as follows: echo-e "\ 033 [word background color; text color m string\ 033 [0m"
Word color: 30-37
Echo-e "\ 033 [30m black words\ 033 [0m"
Echo-e "\ 033 [31m red word\ 033 [0m"
Echo-e "\ 033 [32m green word\ 033 [0m"
Echo-e "\ 033 [33m × × × words\ 033 [0m"
Echo-e "\ 033 [34m blue word\ 033 [0m"
Echo-e "\ 033 [35m purple word\ 033 [0m"
Echo-e "\ 033 [36m Sky Blue character\ 033 [0m"
Echo-e "\ 033 [37m White word\ 033 [0m"
Word background color: 40-47
Echo-e "\ 033 [40 Ten 37m black background white characters\ 033 [0m"
Echo-e "\ 033 [41bot 37m red background white character\ 033 [0m"
Echo-e "\ 033 [42bot 37m White characters on green background\ 033 [0m"
Echo-e "\ 033 [43bot 37m Yellow background White character\ 033 [0m"
Echo-e "\ 033 [44th 37m Blue background White characters\ 033 [0m"
Echo-e "\ 033 [45th 37m purple background white characters\ 033 [0m"
Echo-e "\ 033 [46th 37m Sky Blue background White characters\ 033 [0m"
Echo-e "\ 033 [47umbent 30m black character on white background\ 033 [0m"
Control options description:
\ 33 [0m turn off all properties
\ 33 [1m set high brightness
\ 33 [4m underline
\ 33 [5m flicker
\ 33 [7m reverse display
\ 33 [8m blanking
\ 33 [30m -\ 33 [37m set foreground color
\ 33 [40m -\ 33 [47m set background color
\ 33 [nA cursor up n lines
\ 33 [nB cursor down n lines
\ 33 [move the nC cursor to the right n lines
\ 33 [nD cursor move left n lines
\ 33 [ytrexh sets the cursor position
\ 33 [2J clear screen
\ 33 [K clear the contents from the cursor to the end of the line
\ 33 [s Save cursor location
\ 33 [u restore cursor position
\ 33 [? 25l hide the cursor
\ 33 [? 25h display cursor
Echo check flicker, understroke, color
*******
*****
***
*
Echo-e "[0m\ 033] [0m\ 033 [4m * *] [0m\ n [0m\ n]