commands
time — Measure command duration in Bash
Bash keyword reports real, user and system seconds; distinct from external GNU time. Use a fresh private workspace; No production workload is required.
Formal Syntax & Structure
linux syntaxlinux
time [-p] PIPELINEParameters & Attributes
| Name | Type | Description |
|---|---|---|
| -p | option | Print timing summary in POSIX format. |
| PIPELINE | operand | Bash pipeline or command to time; its status is returned. Timing normally goes to stderr. |
Return Value
exit status and output
The Bash time keyword reports real, user and system time on stderr with -p and returns the status of the timed pipeline. Timing output can be present even when the timed command fails.
Working Example
Example Snippetlinux
{ time -p /bin/true; } 2>&1 | awk '$1=="real" || $1=="user" || $1=="sys" {print $1}'