0

如何将输出 1 和 2 重定向到文件和屏幕?

command 2 1 > /tmp/log and 2 1 screen

所有输出到文件和屏幕

谢谢你

4

2 回答 2

7

tee 命令将输出定向到文件和 tty。

echo 'hi there'  2>&1 | tee outputfile

向输出文件和 tty 写入相同的“hi there”。这会重定向 1 和 2。

根据您的描述尝试脚本:

Linux / Unix Command: script

 Command Library
NAME

script - make typescript of terminal session  
SYNOPSIS

script [-a ] [-f ] [-q ] [-t ] [file ]  
DESCRIPTION

Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).
If the argument file is given, script saves all dialogue in file If no file name is given, the typescript is saved in the file typescript
于 2013-03-12T02:55:29.603 回答
0

我有 1000 个命令

例子

apt-get install;
mc;
apt-get update;
echo "foo";
..
..
..
nano /etc/passwd;
ls /tmp/log;
mc;
screen

我需要将结果发送到屏幕并保存到文件中。

没有人知道什么会运行该命令。

谢谢

于 2013-03-12T14:44:00.323 回答