如何将输出 1 和 2 重定向到文件和屏幕?
command 2 1 > /tmp/log and 2 1 screen
所有输出到文件和屏幕
谢谢
最佳答案
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
关于linux - BASH - 如何将输出 1 和 2 重定向到文件和屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15352480/