15 Practical Examples of ‘echo’ command in Linux

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

29 Responses

  1. Praveen says:

    Provides good understanding over echo command

  2. Shweta says:

    Hi All,

    I am stuck in my task and not able to get through. I would really appreciate your help.

    So, here is the thing.. I am trying to pass a file to mapper (where the required output location is mentioned) using the command.

    # file2broker -f TestfilePlm.txt -q SIABROKER1.INBOUND -m MERT -z appid=PLM0002F 

    trying to pass TestfilePlm.txt file via inbound queue and the mapper should execute the lines for the PLM0002F app id.

    Problem: The output file is not getting generated nor the data or TestfilePlm.txt is in error queue.

    I tried echo $? after file2broker command,it is returning 11 code.
    Can someone please tell me what 11 here signifies?

    I am not sure what I am missing here.

  3. Will Budic says:

    I use alias ?=’echo ‘ in my .bashrc

    So, to echo an calculation:
    ? 2.2*128.56| bc -iq | tail -n 1

    And to echo:
    ? Hello World! Whats up?

  4. Bhagavan says:

    how to display hello in block letters ,to display in red color and blinking effect using echo command in shell scripting
    Plz explain

  5. Mohit Kumar says:

    Great list of echo usage. I was going through a particular example where the need is to reformat linux date into human readable date.

    Like: echo $(date +%Y-%m%d\ %H:%M:%S).

    My question is what are the all types of formatting one can do using echo. for example : Can i make particular word or letter in bold? or any other commonly used formatting.

  6. Dave Williams says:

    I am trying the ‘for do’ loop below and experimenting with the echo options. When I submit the script as follows:

    ./forDoLoop.sh peter pan flies

    the text ‘peter pan flies’ doesn’t stay on the screen, it briefly displays the text but then disappears. Please can you tell me what I am doing wrong in the loop below.

    for do loop
    for TOKEN in $*
    echo -n $TOKEN

  7. Sravanthi says:

    Hi All ,
    I am beginner to Linux Environment. My problem is, i want to append same text to a file multiple times in single command. How to do it.which command i have to use:
    For Single append i am using

    echo “Hello world” >> testfile.txt (for 1 time)
    cat testfile.txt

    if i want to append 10 times that same Hello world , need to write
    echo “Hello world” >> testfile.txt 10 times? or any other possibilities please.

    i want out put like below:

    Hello world
    Hello world
    Hello world
    Hello world
    Hello world

    like 10 times

    • Ravi Saive says:


      Instead of using echo, why not use printf command to repeat a string or text multiple times to a file shown in the below example.

      # printf 'HelloWorld\n%.0s' {1..5} >> ravi.txt
      # cat ravi.txt 

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.