Monday, January 31, 2022

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

Issue

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.


Solution

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



Answered By - hostmaster
Answer Checked By - Katrina (WPSolving Volunteer)