Warm tip: This article is reproduced from serverfault.com, please click

how to use echo command to print out content of a text file?

发布于 2014-03-13 11:52:59

I am trying to figure out what is the usage of this command:

echo < a.txt

According to text book it should redirect a programs standards input. Now I am redirecting a.txt to echo but instead of printing the content of the file it is printing out one empty line! Appreciate if anyone display this behaviour.

Questioner
Bernard
Viewed
0
hostmaster 2018-02-26 15:34:50

echo doesn't read stdin so in this case, the redirect is just meaningless.

echo "Hello" | echo

To print out a file just use the command below

echo "$(<a.txt )"