And display the contents of the file in the stdout using #!/bin/bash

echo"hello" >> ~/Hello 
cat ~/Hello 

should I use tee ~/Hello to display contents of file Hello in stdout ?

  • 5
    That's great! So, what is your question? What part of this is giving you trouble? Please edit and clarify.
    – terdon
    Feb 18, 2015 at 19:48
  • #!/bin/bash echo"hello" >> ~/Hello cat ~/Hello but should I use tee ~/Hello to display contents of file Hello in stdout
    – jackotonye
    Feb 18, 2015 at 19:56
  • @jackotonye What part of the word edit did you not understand. You should improve you post, not comment on comments.
    – Anthon
    Feb 18, 2015 at 21:58
  • You really a cruel person
    – jackotonye
    Feb 19, 2015 at 18:06

1 Answer 1


No, tee is not for displaying the contents of a file. As with most *nix commands, you can see its manual by running man tee. There, you will see:

   tee - read from standard input and write to standard output and files

   Copy standard input to each FILE, and also to standard output.

So, tee is used to write to files. The most common usage is to display text on screen and also save it to a file. For example:

echo "foo" | tee ~/bar

The command above will print foo to your screen (standard output) and also save it to the file ~/bar.

If you want to show the contents of a file, the standard way is precisely what you're doing: cat file. So, cat ~/Hello will show the contents of the file ~/Hello.

By the way, you have a typo in your script. You want echo "hello" not echo"hello".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .