Unix: confusing use of the Tee -command

前端 未结 8 1852
野趣味
野趣味 2021-02-07 14:31

Manual states that the tee is a \"pipe fitting\"-tool. The cases [1] confuse me:

1. case

echo \"foo bar\" | sudo tee -a /path/to/some/fi         


        
8条回答
  •  死守一世寂寞
    2021-02-07 14:33

    tee is used to split a command pipeline, allowing you to save the output of a command to a file and send it along down the pipeline. In the first example you gave::

    echo "foo bar" | sudo tee -a /path/to/some/file
    

    "foo bar" will be echoed to standard output and appended to /path/to/some/file. Think of tee like a "T" joint in a pipe, splitting the output into two other pipes.

提交回复
热议问题