V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
rizon
V2EX  ›  程序员

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

  •  
  •   rizon ·
    othorizon · Apr 29, 2019 · 3969 views
    This topic created in 2555 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
        1
    xml123  
       Apr 29, 2019
    重定向
    dangyuluo
        2
    dangyuluo  
       Apr 29, 2019
    仿佛看到高中的我。`<(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
        3
    iwtbauh  
       Apr 29, 2019 via Android
    <()这是一种 bash 扩展。POSIX 里没有这种语法。

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