Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

unix

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.

like image 339
Bernard Avatar asked Mar 13 '14 11:03

Bernard


1 Answers

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

like image 188
hostmaster Avatar answered Oct 23 '22 04:10

hostmaster