With the Linux echo command, we can output the text we want to the terminal screen, or we can use it to create a new file.

Create file

To create a file with the echo command, a greater than sign is placed after the echo command and the file name is written after the sign. When we look at the format, we see that it is similar to the cat command in terms of usage.

echo > hello.txt

If you want to write something in the file to be created, write in double quotes after the echo command and specify the file name after the greater than sign.

echo "Hello World" > hello.txt

To add text to an existing file, the same method is used, but this time two greater than one sign is used, not one greater than one sign.

echo >> hello.txt

File/Directory viewing

Files and directories in the current directory can be viewed with the echo command. By putting * after the echo command, all files/directories can be printed on the screen.

echo *

To print only files/directories that start with a certain letter/number, the corresponding characters are written after the echo command and an asterisk is added to the end. For example, I will print all directories and files that start with the letter b.

echo b*

To print only files/directories ending with a certain letter/number, an asterisk is written after the echo command and the relevant characters are added to the end. For example, I will print all directories and files ending with the letter b.

echo *b

Finally, I will show you how to do 4 operations on the terminal screen with the echo command.

echo $((4*3))
echo $((10/3))

For other parameters, you can get help with the help echo or man echo command.