How to use the echo command in Linux?

  
                

In Linux, echo is a DOS batch processing command that can be used to set the display state of the command line or create new files. This article will explain in detail how to use the Linux command echo?

echo: echo [-neE] [arg ...] string

echo will be sent to the input standard output. The output strings are separated by white space characters and a newline number is added at the end.

Options:

-n Don't wrap at the end

-e Interpret with backslash

-E Suppress backslash interpretation

When using the -e option, if the following characters appear in the string, they are treated specially instead of being treated as normal text:

•\\a gives a warning;

•\\b deletes the previous character;

•\\c does not add a newline symbol at the end;

•\\f wraps the line but the cursor remains in its original position; Br>

•\ Wrap and move the cursor to the beginning of the line;

•\ The cursor moves to the beginning of the line, but does not wrap;

•\\t Horizontal tabulation ;

•\\v vertical tab;

•\\\\ insert\\character;

•\ nn insert ASCII represented by nnn (octal) Characters;

Use the echo command to print the text of special effects:

\\e[nm n is a numeric code, multiple separated by <;”

text color code : reset=0, black=30, red =31, green=32, yellow=33, blue=34, magenta=35, cyan=36, white=37

background color code: reset=0, black=40, red=41, Green=42, yellow=43, blue=44, magenta=45, cyan=46, white=47

Other numeric parameters: 0 turn off all attributes, 1 set high brightness (bold), 4 underline , 5 flashes, 7 reverses, 8 blanks

Text color:

echo -e “\\e[31mThis is red text\\e[0m”This is red text

Background color:

echo -e “\\e[42mGreed Background\\e[0m”Greed Background

Text bold:

echo -e “ \\e[1mThis is strong text\\e[0m”This is strong text

The above is the entire content of the echo command in Linux. It can be seen that the main function of the echo command is to display the internal information of the command. .

Copyright © Windows knowledge All Rights Reserved