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

shell 中的自定义文件描述符有什么用途?

  •  
  •   Davic1 · May 10, 2019 · 1523 views
    This topic created in 2557 days ago, the information mentioned may be changed or developed.

    比如自定义读的文件描述符 4

    exec 4<input.txt

    echo "This is output line" > input.txt #向 input.txt 写入一些内容

    cat < &4 #输出 input.txt 中的内容.


    但是有没有更实际用途?

    1 replies    2019-05-10 14:32:40 +08:00
    geelaw
        1
    geelaw  
       May 10, 2019 via iPhone
    你想要在程序里处理多个 stream 的时候就有用,比如你可以写一个 shell script 通过 4 来传输一些 verbose 信息
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   841 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 20:51 · PVG 04:51 · LAX 13:51 · JFK 16:51
    ♥ Do have faith in what you're doing.