[英]BASH - how to redirect output 1 and 2 to file and screen?
如何将输出1和2重定向到文件和屏幕?
command 2 1 > /tmp/log and 2 1 screen
所有输出到文件和屏幕
谢谢
tee命令将输出定向到文件和tty。
echo 'hi there' 2>&1 | tee outputfile
将相同的“ hi there”写入到outputfile和tty中。 这将重定向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
我有1000个命令
例
apt-get install;
mc;
apt-get update;
echo "foo";
..
..
..
nano /etc/passwd;
ls /tmp/log;
mc;
screen
我需要将结果发送到屏幕上并保存到文件中。
没有人知道什么将运行命令。
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.