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

unix-如何使用echo命令打印出文本文件的内容?

(unix - how to use echo command to print out content of a text file?)

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

我想弄清楚此命令的用途:

echo < a.txt

根据教科书,它应该重定向程序标准的输入。现在,我将a.txt重定向到echo,但是不是打印文件的内容,而是打印出一个空行!感谢有人显示此行为。

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

echo 不读取stdin,因此在这种情况下,重定向只是毫无意义。

echo "Hello" | echo

要打印文件,只需使用以下命令

echo "$(<a.txt )"