簡體   English   中英

BASH-如何將輸出1和2重定向到文件和屏幕?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM