如何将控制台输出重定向到文本文件 [英] How to redirect console output to a text file

查看:1590
本文介绍了如何将控制台输出重定向到文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行一个Perl程序。无论打印在我的控制台上,我想将
重定向到一个文本文件。

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

推荐答案

因为这是通过命令行处理重定向,例如

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

perl -w my_program.pl > my_output.txt

如果你还想包括stderr输出,你可以这样做bash):

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

这篇关于如何将控制台输出重定向到文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆