echo Linux Command Cheatsheet

967




echo Linux Command used to output text to screen. This is available in most of the operating systems along with Linux systems.

Syntax

echo [option(s)] [string(s)]

Examples

echo Hello World! #=> Hello World!
x=5
echo $x #=> 5
x=8
echo x value is $x #=> x value is 8
echo Hello \nWorld! #=> Hello
                    #   World!

Note: \n is for new line

echo Hello \tWorld! #=> Hello   World!

`Note: \t is for tab

echo * #=> Prints files and folders of current directory
echo *.txt #=> Prints all .txt files from current directory
  • Using option new Line ‘\n‘ and horizontal tab ‘\t‘ simultaneously.
$ echo -e "\n\Onecompiler \n\tis \n\ta \n\tcommunity \n\tof \n\tNerds" 

	Onecompiler
	is 
	a 
	community 
	of
	Nerds