命令输出重定向到文件和终端 [英] command output redirect to file and terminal

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

问题描述

我试图抛出命令的输出也文件加上控制台。这是因为我想保持输出的记录文件。我做以下,并追加到文件中,但不打印 LS 输出端子。

  $ LS 2  - ;&放1 GT; /tmp/ls.txt


解决方案

是的,如果你重定向输出,它不会出现在控制台上。使用 T恤

  LS 2  - ;&放大器; 1 |三通/tmp/ls.txt

I am trying to throw command output to file plus console also. This is because i want to keep record of output in file. I am doing following and it appending to file but not printing ls output on terminal.

$ls 2>&1 > /tmp/ls.txt

解决方案

Yes, if you redirect the output, it won't appear on the console. Use tee.

ls 2>&1 | tee /tmp/ls.txt

这篇关于命令输出重定向到文件和终端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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