User Tools

Site Tools


The echo command in Linux and Unix-like systems is used to display a line of text or a variable's value on the screen or in a file.

Here are a few examples of how the echo command can be used:

1. Display a line of text on the screen:

echo Hello, World!

2. Display the value of a variable:

echo $HOME

This will display the value of the HOME environment variable)

2. Write text to a file:

echo Hello, World! > testworld.txt

The above will create a file named “testworld.txt” and write the text “Hello, World!” to it)

3. Append text to a file:

echo How are you? >> testworld.txt

The above will add the text “How are you?” to the end of the file “testworld.txt”. It's also possible to use the echo command to create a new line, by using echo -e with an escape sequence \n

For example:

echo -e "Hello\nWorld"

this will print “Hello” in a new line and “World” in next line

echo command is widely used in shell scripting and command line scripting, it's one of the most basic command and considered as one of the building blocks for more complex commands.

unix_commands/echo.txt · Last modified: 2023/01/17 08:11 by admin

CIFNet is a leading hosting solution provider, offering a wide range of services including IP bandwidth, co-location, VMware and KVM hosting.
Host Your Site with CIFNet!