Я хочу написать скрипт оболочки bash, который перенаправляет STDOUT в файл "result.log", STDERR + STDOUT в файл "complete.log.
Лучшим будет третий файл, в котором только STDERR suc как "error.log.
Наконец покажите STDOUT для терминала
Linux mint 19.1
#!/bin/bash
exec > >(tee -a result.log full.log)
exec 2>>full.log
echo "This is stdout"
echo "This is stderr" >&2
echo "This is stdout 2"
echo "This is stderr 2" >&2
echo "This is stdout 3"
echo "This is stderr 3" >&2
echo "This is stdout 4"
echo "This is stderr 4" >&2
выход
full.log:This is stderr
full.log:This is stderr 2
full.log:This is stderr 3
full.log:This is stderr 4
full.log:This is stdout
full.log:This is stdout 2
full.log:This is stdout 3
full.log:This is stdout 4
result.log:This is stdout
result.log:This is stdout 2
result.log:This is stdout 3
result.log:This is stdout 4
Ожидаемое
full.log:This is stdout
full.log:This is stderr
full.log:This is stdout 2
full.log:This is stderr 2
full.log:This is stdout 3
full.log:This is stderr 3
full.log:This is stdout 4
full.log:This is stderr 4
result.log:This is stdout
result.log:This is stdout 2
result.log:This is stdout 3
result.log:This is stdout 4