script

File Write

The content appears among the log prints.

script -q -c '# DATA' /path/to/output-file

Shell

script -q /dev/null