Bash Echo – Syntax & Examples

Bash Echo Command

Bash Echo is a command in bash shell that writes its arguments to standard output.

Whatever you see in the terminal is because of echo command being executed by other programs.

Following are the topics we shall go through in this tutorial :

Syntax

Following is the syntax of echo command

Options Available with Echo Command

Following are the options available with echo command :

OptionDescriptionExample
-nTrailing outline is omitted echo -n "Learn Bash"
-EDisable interpretation of backslash escaped characters echo -E "Learn\nBash"
-eEnable interpretation of backslash escaped characters echo -e "Learn\nBash"

 

Examples

Terminal is a bash shell program. It can execute bash commands directly in the terminal or you may create a bash script file and run the file in terminal.

Example – Simple Echo Example

Directly on Terminal

Using Script File

When you run above bash script in Terminal

 

Example – Echo without trailing newline

Directly on Terminal

Using Script File

When you run above bash script in Terminal

 

Example – Echo command interpreting backslash escaped characters

Directly on Terminal

Using Script File

When you run above bash script in Terminal

 

Example – Echo without interpretation of escaped characters

Directly on Terminal

Using Script File

When you run above bash script in Terminal

 

Conclusion :

In this Bash TutorialBash Echo, we have learnt the syntax of echo command, options available with echo command, with example Bash Script Files.