← 返回命令列表

Linux command

script 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Record

script

Record

script [path/to/session.out]

Append

script -a [logfile.log]

Record

script -t 2> [path/to/timing_file]

Write

script -f [path/to/file]

Execute

script -q [logfile.log]

Stop

exit

说明

script records all terminal output to a typescript file. It creates a forked shell and captures everything displayed on the terminal, including input and output, until the session ends with exit or Ctrl-D. The recorded session can be replayed using scriptreplay when timing information is captured. This is useful for creating tutorials, documenting procedures, or auditing terminal sessions.

参数

-a, --append
Append output to an existing file
-f, --flush
Flush output after each write
-q, --quiet
Be quiet (suppress start and done messages)
-t, --timing=_file_
Output timing data for scriptreplay
-c, --command _command_
Run command rather than interactive shell
-e, --return
Return exit code of the child process
-O, --log-out _file_
Log stdout to file (structured)

FAQ

What is the script command used for?

script records all terminal output to a typescript file. It creates a forked shell and captures everything displayed on the terminal, including input and output, until the session ends with exit or Ctrl-D. The recorded session can be replayed using scriptreplay when timing information is captured. This is useful for creating tutorials, documenting procedures, or auditing terminal sessions.

How do I run a basic script example?

Run `script` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a, --append do in script?

Append output to an existing file