1

Recently, I needed to write my terminal output down. And I've read this question to find the answer. But now, I would like to write my commands down (which I type in terminal, for example:sudo apt update etc.) to store the history of what I have done earlier.

How can I save my input to file and simultaneously run this input?

P.S. script comprises too many rubbish of type: ^[[? ^[[m etc. I would like to get more simple way, which saves my commands only.

1 Answers1

3

Use the tee command to write your input to a file and also to stdout, piped to your program. e.g. for bash:

tee foo |bash
ls
df
^c

So the foo file contains

ls
df

and bash outputs to your terminal.

ubfan1
  • 17,838