Also das ist, was ich denke, dass Sie tun möchten.
Zur Ausgabe auf stdout zu halten, sondern gehen auch
long_proc(){
exec 4>&1
#redirect fd4(currently nothing hopefully) to stdout
exec 1>&3
#redirect stdout to fd3(also hopefully unused)
#Note you have 5 more to choose from if they are in use.
echo Just log
#script1 that generate output1
echo Log and Stdout | tee >(cat - >&4)
#script1 that generate output2
# Tee into a subproc to cat data into fd4 pointing to stdout
#The tee'd data also goes to fd3
exec 1>&4
# set fd1 back to stdout
exec 4>&-
#close fd4
}
long_proc 3> log
#Send fd3 to log, stdout is untouched and does whatever you want.
So umleiten alle Ausgaben an fd3, die dann alle in log verrohrt ist einzureichen. T-Stück in stdout alles, das Sie auch in stdout sein möchten.
Vorteil davon ist, dass man dann Rohr wie
long_proc 3> log | sed 's/^/Piped and /'
'long_proc> /tmp/debug.log 2> & 1 '? – Cyrus
Verwenden Sie den Befehl tee – 123
@cyrus, wird es vollständige Protokoll in die Datei sowie stdout ausgeben, richtig? Aber meine Anforderung ist etwas, was anders ist. Die Ausgabe eines Befehls muss in stdout umgeleitet werden. – shafeeq