Learn echo command in Termux
The echo command in Linux is a built-in command that allows users to display lines of text or strings that are passed as arguments.
It is commonly used in shell scripts and batch files to output status text to the screen or a file and its format is “echo [option] [string]“
[options] = The various options available for modifying the behavior of the
[string] = It is the string that we want to display.
echo command[string] = It is the string that we want to display.
Basic Usage: Displaying Text/String
The most straightforward usage of the echo command is to display a text or string on the terminal. To do this, you simply provide the desired text or string as an argument to the echo command echo [string]
Example:
echo "hello world"
Options Available:
Note: -e here enables the interpretation of backslash escapes
\b : it removes all the spaces in between the text
\c : suppress trailing new line with backspace interpreter ‘-e’ to continue without emitting new line.
\t : this option is used to create horizontal tab spaces.
\r : carriage return with backspace interpreter ‘-e’ to have specified carriage return in output.
\v : this option is used to create vertical tab spaces.
\a : alert return with backspace interpreter ‘-e’ to have sound alert.
echo * : this command will print all files/folders, similar to ls command.
-n : this option is used to omit echoing trailing newline.
Redirecting echo Output:
The output of the echo can be redirected to a file instead of displaying it on the terminal. We can achieve this by using the > or >> operators for output redirection.
echo "Welcome to termux" >> termux.txt
This will write the output of the echo command to the file name output.txt. File will be overwritten if it already exists.
The echo command serves as a fundamental tool for echoing text in the terminal, offering a quick and efficient way to communicate information. 📢

Comments
Post a Comment