Print String to Output

To print a string in Bash, use echo command. Provide the string as command line argument to echo command.


The syntax to initialise a string in Bash is

echo string_variable_or_value


In the following examples, we cover scenarios where we print a string value or print a value in variable to output, using echo command.

Print String Value to Output

In the following script, we print the string value “hello world” to output.

echo "hello world"


hello world

Print String Value in Variable to Output

In the following script, we initialise a variable with string value “Hello World” and print it to output.

str="hello world"
echo $str


hello world


In this Bash Tutorial, we have learnt how to print a string to output in Bash shell.