Copied to clipboard


The echo command can output text to the terminal or a file.

Output text to the terminal

Output text to a file


Output text to the terminal:

echo "Hello, world!"

Output text to a file:

echo "Some text" > file.txt

Append text to a file:

echo "More text" >> file.txt

Display the current working directory:

echo $PWD

Display the current username:

echo $USER

Output a variable with text:

echo "My name is $name"

Disable the newline character:

echo -n "This text will be printed on the same line"

Enable escape characters:

echo -e "This text contains a tab character:\\tTab"