• 请不要在回答技术问题时复制粘贴 AI 生成的内容
rizon
V2EX  ›  程序员

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

  •  
  •   rizon ·
    othorizon · Apr 29, 2019 · 4552 views
    This topic created in 2746 days ago, the information mentioned may be changed or developed.
    
    $ echo 123|cat -
    
    $ cat <(echo 123)
    
    $ cat <<EOF
    > 123
    > EOF
    
    
    

    分享几种 linxu 的符号用法

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

    10 replies  •  2019-04-30 13:49:31 +08:00
    xml123
    xml123
    Apr 29, 2019
    1
    重定向
    dangyuluo
    dangyuluo
    Apr 29, 2019
    2
    仿佛看到高中的我。`<(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
    iwtbauh
    Apr 29, 2019 via Android
    3
    <()这是一种 bash 扩展。POSIX 里没有这种语法。

    如果要考虑可移植性,应该尽量避免这种写法
    msg7086
    msg7086
    Apr 30, 2019
    4
    这都是 Bash 里的东西,和 Linux 没关系。我 Windows 下的 Bash 也支持这些东西。
    ceyes
    ceyes
    Apr 30, 2019❤️1
    5
    $ 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
    nutting
    Apr 30, 2019
    6
    管道和重定向,搜搜资料,windows 的命令行也有这些概念
    zbinlin
    zbinlin
    Apr 30, 2019
    7
    flanker
    flanker
    Apr 30, 2019
    8
    管道
    ysc3839
    ysc3839
    Apr 30, 2019 via Android
    9
    @ceyes '-' 应该是程序自己处理的吧?执行 `echo test > -` 可以创建这个文件。
    kimiichan
    kimiichan
    Apr 30, 2019
    10
    进程替换
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2850 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 11:00 · PVG 19:00 · LAX 03:00 · JFK 06:00
    ♥ Do have faith in what you're doing.