
就像图像一样。所有命令都是相似的。我知道怎么用,但我不知道细节。会有人知道吗?非常感谢。
# does `cat` read fd and print?
$ cat file
# does `cat` read from stdin and print?
$ cat < file
$ cat - < file
# with heredoc or herestring, what methods `cat` command use to read from heredoc?stdin?
$ cat << EOF
heredoc> test
heredoc> EOF
test
$ cat <<< "test"
$ cat - << EOF
heredoc> test
heredoc> EOF
test
$ cat - <<< "test"
# and I dont why these commands works?
$ cat <(echo "test")
$ cat - <<(echo "test")
# why this command doesn't work?
$ cat - <(echo "test")发布于 2017-01-14 04:34:52
一些阅读材料,全部来自非常有用的巴什手册:
<filename) --导致标准输入重定向到文件filename<<WORD) -导致标准输入从下一行重定向到脚本源,直到但不包括行WORD<<<"string") --导致标准输入重定向到字符串string (就像字符串被写入临时文件,然后标准输入重定向到该文件一样)<(command)) --启动一个执行command的进程,并将一个名称插入到执行文件名的命令行中,这样从该“文件”中读取就会产生该命令的输出。使用-表示源文件是标准输入,这在许多命令中是常见的,并且是Posix推荐的。如果没有指定文件,则从标准输入读取许多命令。有些,比如cat,实现了两种方式来表示意图是从标准输入中读取。
注意,-和<(command)都是文件名参数,而<filename、<<WORD和<<<"string"是重定向。因此,虽然它们表面上看起来很相似,但它们在引擎盖下却有很大的不同。它们的共同点是它们与输入有关;其中一些(但不是这里的文档/字符串)与输出有关,使用的是>而不是<。
https://stackoverflow.com/questions/41646782
复制相似问题