commands

ps — process snapshot

Select a process by PID and report requested columns. STAT starts with a state letter; output is a momentary observation. Avoid treating names or PIDs as durable identity. Use a fresh private workspace, ordinary user and bounded child processes; no sudo.

Formal Syntax & Structure

linux syntaxlinux
ps -p PID -o FORMAT

Parameters & Attributes

NameTypeDescription
-poptionPID selection
-ooptionoutput fields
PIDoperandProcess ID or comma-separated PID list for -p.
FORMAToperandOutput column list for -o; e.g. comm= suppresses that column heading.

Return Value

exit status and output

Select a process by PID and report requested columns. STAT starts with a state letter; output is a momentary observation. Avoid treating names or PIDs as durable identity.

Working Example

Example Snippetlinux
name=$(ps -p "$$" -o comm=) || exit 1test -n "$name" || exit 1printf "%s\n" "$name"
Linux Reference