How to redirect console output to a text file

后端 未结 4 2001
眼角桃花
眼角桃花 2020-12-31 17:15

I am executing a Perl program. Whatever is being printed on my console, I want to redirect that to a text file.

4条回答
  •  孤城傲影
    2020-12-31 17:19

    The preferred method for this is to handle redirection via the command line, e.g.

    perl -w my_program.pl > my_output.txt
    

    If you want to also include stderr output then you can do this (assuming your shell is bash):

    perl -w my_program.pl &> my_output.txt
    

提交回复
热议问题