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] PIPELINE

Parameters & Attributes

NameTypeDescription
-poptionPrint timing summary in POSIX format.
PIPELINEoperandBash 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}'
Linux Reference