echo

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 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 "bhai4you"

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.


\t : this option is used to create horizontal tab spaces.


\n : this option creates a new line from where it is used.


\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 bhai4you.com" >> bhai4you.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. 📢

    Share this article
    Shareable URL
    Prev Post

    ps

    Next Post

    nano

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Read next
    Ads Blocker Image Powered by Code Help Pro

    Ads Blocker Detected!!!

    We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

    Powered By
    Best Wordpress Adblock Detecting Plugin | CHP Adblock