How to redirect output to a file and stdout

后端 未结 10 1572
借酒劲吻你
借酒劲吻你 2020-11-22 08:11

In bash, calling foo would display any output from that command on the stdout.

Calling foo > output would redirect any output from that

10条回答
  •  猫巷女王i
    2020-11-22 08:48

    < command > |& tee filename # this will create a file "filename" with command status as a content, If a file already exists it will remove existed content and writes the command status.

    < command > | tee >> filename # this will append status to the file but it doesn't print the command status on standard_output (screen).

    I want to print something by using "echo" on screen and append that echoed data to a file

    echo "hi there, Have to print this on screen and append to a file" 
    

提交回复
热议问题