echo -e command Detailed
https://www.cnblogs.com/karl-python/p/9261920.html
In php echo is then entered in linux is not also enter it, certainly echo in input linux but also its use more parameters and can take something stronger than php, let's look at an article about linux echo command and introduction -n, -e parameter Description bar, as shown below.
echo command for printing the variable value of the shell in the shell, or directly output the specified string. linux echo command, very commonly used in shell programming, print variable value at the time the terminal is often used, it is necessary to understand the function usage under the echo of the echo command is to display a text on the display, a general play prompts.
grammar
echo (option) (parameter) option
-e: activate the escape character. When you use the -e option, if the character appears in the string is particularly to be addressed, it will not as a general text output:
• \ a warning sound;
• \ former b to delete a character;
• \ c Finally, do not add line breaks;
• \ f new line but the cursor still remain in the original location;
• \ the n-Wrap and move the cursor to the first line;
• \ r cursor to the beginning of the line, but do not wrap;
• \ t insert the Tab;
• \ v and \ f the same;
• insert \\ \ character;
• \ nnn inserted nnn (octal) ASCII character represented;
parameter
Variable: Specifies the variable you want to print.
Examples
Print text with color with the echo command:
Letter color:
-e echo "\ E [. 1; 31mThis IS Red text \ E [0m"
This text IS Red • \ E [. 1; 31M set the color to red
• \ e 0m color reset to return [
Color Code: Reset = 0, 30 = black, red = 31, green = 32, 33 = yellow, blue = 34, 35 = magenta, cyan = 36, 37 = white
Background color:
-e echo "\ E [. 1; 42mGreed Background \ E [0m"
Greed Background Color code: Reset = 0, 40 = black, red = 41, green = 42, 43 = yellow, blue = 44, Magenta = 45 cyan = 46, 47 = white
Flashing text:
echo -e "\ 033 [37; 31; 5mMySQL Server Stop ... \ 033 [39; 49; 0m"
red digital numbers at the other parameters: 0 Close all attributes, a set of high brightness (in bold), 4 underline, blinking 5, 7 reverse display, blanking 8
No Wrap output echo -n
$ echo -n "123"
$ echo "456"
The final output of
123456
Instead of
123
456
echo -e handle special characters
If the character appears in the string, then be treated specially, will not it as normal text output:
\ a warning sound;
\ b to delete a character before;
\ c finally not add line breaks;
\ f new line but the cursor still remain in the original location;
\ the n-Wrap and move the cursor to the first line;
\ r move the cursor to the line first, it does not wrap;
\ t insert the Tab;
\ v and \ f the same;
\\ inserted into the \ character;
\ nnn inserted nnn (octal) ASCII character represented;
The following example to illustrate this:
$ echo -e "a \ bdddd" // will be erased in front of a
dddd
$ echo -e "a \ adddd" // output will also sound an alarm
adddd
$ echo -e "a \ ndddd" // Wrap
A
dddd
We use linux in the process, often to download the installation package, download progress indication when that is not more fun, the percentage of the download progress in changing the use of echo -e and -n parameters we can achieve the effects.
******************************************************************************************************************************************************************************************************************
- echo -e "\ 033 [background color; font color string m \ 033 [0m
Format: echo -e "\ 033 [Word background color; font color string m \ 033 [0m"
For example:
echo -e "\ 033 [41; 36M something here Wallpaper \ 033 [0m"
wherein position 41 is representative of background, position 36 is representative of the color of a word
that is the beginning and end of the color ascii code calls.
\ 033 [; m ...... \ 033 [0m
word background color range: 40 ---- 49
40: black
41: dark red
42: green
43: yellow
44: blue
45: purple
46: dark green
47: white
words color: 30 ----------- 39
30: black
31: red
32: green
33: yellow
34: blue
35 : purple
36: dark Green
37: white
========================================= DESCRIPTION ====== ANSI control code
\ 33 [0m turn off all attributes
\ 33 [1M set high brightness
\ 33 [4M underlined
\ 33 [scintillation 5m
\ 33 [7M reverse display
\ 33 [8M blanking
\ 33 [ 30m - \ 33 [37m disposed foreground
\ 33 [40m - \ 33 [ 47m background color
\ 33 [nA cursor on the line n
\ 33 [nB of n lines cursor down
\ 33 [nC cursor right row n
\ 33 [nD cursor left row n
\ 33 [y; xH set the cursor position
\ 33 [2J clear screen
\ 33 [K clears the contents from the cursor to the end of the
\ 33 [S save cursor position
\ 33 [U restore the cursor location
? \ 33 [25L hide the cursor
\ 33 [ ? 25h display cursor
In php echo is then entered in linux is not also enter it, certainly echo in input linux but also its use more parameters and can take something stronger than php, let's look at an article about linux echo command and introduction -n, -e parameter Description bar, as shown below.
echo command for printing the variable value of the shell in the shell, or directly output the specified string. linux echo command, very commonly used in shell programming, print variable value at the time the terminal is often used, it is necessary to understand the function usage under the echo of the echo command is to display a text on the display, a general play prompts.
grammar
echo (option) (parameter) option
-e: activate the escape character. When you use the -e option, if the character appears in the string is particularly to be addressed, it will not as a general text output:
• \ a warning sound;
• \ former b to delete a character;
• \ c Finally, do not add line breaks;
• \ f new line but the cursor still remain in the original location;
• \ the n-Wrap and move the cursor to the first line;
• \ r cursor to the beginning of the line, but do not wrap;
• \ t insert the Tab;
• \ v and \ f the same;
• insert \\ \ character;
• \ nnn inserted nnn (octal) ASCII character represented;
parameter
Variable: Specifies the variable you want to print.
Examples
Print text with color with the echo command:
Letter color:
-e echo "\ E [. 1; 31mThis IS Red text \ E [0m"
This text IS Red • \ E [. 1; 31M set the color to red
• \ e 0m color reset to return [
Color Code: Reset = 0, 30 = black, red = 31, green = 32, 33 = yellow, blue = 34, 35 = magenta, cyan = 36, 37 = white
Background color:
-e echo "\ E [. 1; 42mGreed Background \ E [0m"
Greed Background Color code: Reset = 0, 40 = black, red = 41, green = 42, 43 = yellow, blue = 44, Magenta = 45 cyan = 46, 47 = white
Flashing text:
echo -e "\ 033 [37; 31; 5mMySQL Server Stop ... \ 033 [39; 49; 0m"
red digital numbers at the other parameters: 0 Close all attributes, a set of high brightness (in bold), 4 underline, blinking 5, 7 reverse display, blanking 8
No Wrap output echo -n
$ echo -n "123"
$ echo "456"
The final output of
123456
Instead of
123
456
echo -e handle special characters
If the character appears in the string, then be treated specially, will not it as normal text output:
\ a warning sound;
\ b to delete a character before;
\ c finally not add line breaks;
\ f new line but the cursor still remain in the original location;
\ the n-Wrap and move the cursor to the first line;
\ r move the cursor to the line first, it does not wrap;
\ t insert the Tab;
\ v and \ f the same;
\\ inserted into the \ character;
\ nnn inserted nnn (octal) ASCII character represented;
The following example to illustrate this:
$ echo -e "a \ bdddd" // will be erased in front of a
dddd
$ echo -e "a \ adddd" // output will also sound an alarm
adddd
$ echo -e "a \ ndddd" // Wrap
A
dddd
We use linux in the process, often to download the installation package, download progress indication when that is not more fun, the percentage of the download progress in changing the use of echo -e and -n parameters we can achieve the effects.
******************************************************************************************************************************************************************************************************************
- echo -e "\ 033 [background color; font color string m \ 033 [0m
Format: echo -e "\ 033 [Word background color; font color string m \ 033 [0m"
For example:
echo -e "\ 033 [41; 36M something here Wallpaper \ 033 [0m"
wherein position 41 is representative of background, position 36 is representative of the color of a word
that is the beginning and end of the color ascii code calls.
\ 033 [; m ...... \ 033 [0m
word background color range: 40 ---- 49
40: black
41: dark red
42: green
43: yellow
44: blue
45: purple
46: dark green
47: white
words color: 30 ----------- 39
30: black
31: red
32: green
33: yellow
34: blue
35 : purple
36: dark Green
37: white
========================================= DESCRIPTION ====== ANSI control code
\ 33 [0m turn off all attributes
\ 33 [1M set high brightness
\ 33 [4M underlined
\ 33 [scintillation 5m
\ 33 [7M reverse display
\ 33 [8M blanking
\ 33 [ 30m - \ 33 [37m disposed foreground
\ 33 [40m - \ 33 [ 47m background color
\ 33 [nA cursor on the line n
\ 33 [nB of n lines cursor down
\ 33 [nC cursor right row n
\ 33 [nD cursor left row n
\ 33 [y; xH set the cursor position
\ 33 [2J clear screen
\ 33 [K clears the contents from the cursor to the end of the
\ 33 [S save cursor position
\ 33 [U restore the cursor location
? \ 33 [25L hide the cursor
\ 33 [ ? 25h display cursor