Linux cat <(echo 123) 这种用法叫什么?顺便分享一下 Linux 中的符号

2019 年 4 月 29 日
 rizon

$ echo 123|cat -

$ cat <(echo 123)

$ cat <<EOF
> 123
> EOF


分享几种 linxu 的符号用法

然后问问 有谁知道 <()这种用法是什么??

3878 次点击
所在节点    程序员
10 条回复
xml123
2019 年 4 月 29 日
重定向
dangyuluo
2019 年 4 月 29 日
仿佛看到高中的我。`<(echo 123)`会生成一个文件描述符( fd ),然后将这个描述符定向到当前命令的 stdin or $0

你应该也会喜欢 hear string 和 here document

https://www.tldp.org/LDP/abs/html/x17837.html

http://tldp.org/LDP/abs/html/here-docs.html
iwtbauh
2019 年 4 月 29 日
<()这是一种 bash 扩展。POSIX 里没有这种语法。

如果要考虑可移植性,应该尽量避免这种写法
msg7086
2019 年 4 月 30 日
这都是 Bash 里的东西,和 Linux 没关系。我 Windows 下的 Bash 也支持这些东西。
ceyes
2019 年 4 月 30 日
$ echo 123 | cat -
管道将 stdout 传输到 stdin,这里用“-”代表标准输出文件‘/dev/stdout ’,类似的用法还可以看下 xargs
https://www.tldp.org/LDP/abs/html/io-redirection.html
https://www.ibm.com/developerworks/cn/linux/l-lpic1-103-4/index.html

$ cat <(echo 123)
subshell 并重定向
https://www.tldp.org/LDP/abs/html/subshells.html

$ cat <<EOF
> 123
> EOF
Here Documents,参考: http://tldp.org/LDP/abs/html/here-docs.html
nutting
2019 年 4 月 30 日
管道和重定向,搜搜资料,windows 的命令行也有这些概念
zbinlin
2019 年 4 月 30 日
flanker
2019 年 4 月 30 日
管道
ysc3839
2019 年 4 月 30 日
@ceyes '-' 应该是程序自己处理的吧?执行 `echo test > -` 可以创建这个文件。
kimiichan
2019 年 4 月 30 日
进程替换

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://study.congcong.us/t/559921

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX