Bash read/write file descriptors — seek to start of file

前端 未结 7 1817
暗喜
暗喜 2020-12-08 08:48

I tried to use the read/write file descriptor in bash so that I could delete the file that the file descriptor referred to afterward, as such:

F=$(mktemp)
ex         


        
7条回答
  •  清歌不尽
    2020-12-08 09:03

    Try changing the sequence of commands:

    F=$(mktemp tmp.XXXXXX)
    exec 3<> "$F"
    echo "Hello world" > "$F"
    rm -f "$F"
    
    #echo "Hello world" >&3
    cat <&3
    

提交回复
热议问题