What is the shortest way to redirect: $PROMPT, last executed command, stdout and stderr into single file?

Of course, we might use &> to redirect stdout and stderr into single file and then add $PROMPT and $!! and at the beginning and at the end of file, respectively.

I would like to see my log file as:


1 Answer 1


What you wan tot achieve is a typescript of a terminal session. For this you could use script.

Start recording with:

$ script logfile
Script started, file is logfile

Now type your commands and, when finished, exit with ctrl-d. You can now view that file with:

less -r logfile

In that file is the input, output, error messages, the shell prompt and so on.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .