user3027198
user3027198

Reputation: 303

How to stop writing to log file in BASH?

I'm using this code to write all terminal's output to the file

exec > >(tee -a "${LOG_FILE}" )
exec 2> >(tee -a "${LOG_FILE}" >&2)

How to tell it to stop? If, for example, I don't want some output to get into log..

Thank you!

Upvotes: 0

Views: 1996

Answers (2)

shellter
shellter

Reputation: 37268

It's not completely clear what your goal is here, but here is something to try.

Do you know about the script utility? You can run script myTerminalOutputFile and any commands and output after that will be captured to myTerminalOutputFile. The downside is that it captures everything. You'll see funny screen control chars like ^[[5m;27j. So do a quick test to see if that works for you.

To finish capturing output just type exit and you are returned to you parent shell cmd-line.

Warning: check man script for details about the inherent funkyness of your particular OS's version of script. Some are better than others. script -k myTerminalOutputFile may work better in this case.

IHTH

Upvotes: 2

Bijoy
Bijoy

Reputation: 167

You may pipe through "sed" and then tee to log file

Upvotes: 0

Related Questions