How to redirect console output to file and STILL get it in the console?

前端 未结 2 575
囚心锁ツ
囚心锁ツ 2021-02-02 10:36

I want to run an ANT script which prompts the user for input, so it needs to be interactive through the console. at the same time I want to log the console content to a log file

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-02 11:33

    You can use tee.

    Example:

    $ echo "Hello, world" | tee /tmp/outfile
    Hello, world
    $ cat /tmp/outfile
    Hello, world
    

    tee writes its stdin to both stdout as well as one or more files given on the command line.

提交回复
热议问题