# PS4

*noun*

say it: **“PEE-ES-FOR”** **/ˌpiˌɛsˈfɔr/**

The bash variable that holds the text printed in front of each line when a script is traced.

## What is **PS4** in bash?

`PS4` holds the text bash prints in front of each line of a trace from `bash -x`, the way `PS1` holds your prompt. It's `+ ` unless you change it. Set it near the top of a script, in single quotes, and `${LINENO}` puts each traced command's line number in front of it.

```bash
PS4='+ line ${LINENO}: '
set -x
name=$(basename inbox/IMG_0412.jpg)
# ++ line 3: basename inbox/IMG_0412.jpg
# + line 3: name=IMG_0412.jpg
```

## In a sentence

- “Sam set **PS4** to show line numbers, and the trace pointed straight at line 32.”
- “Like PS1 for the prompt, **PS4** is a variable you can change.”

Level: Freelancer · [More Unix terms at this level](https://www.ask-codey.com/glossary?category=unix&level=4)

Updated: November 10, 2026

Source: https://www.ask-codey.com/glossary/ps4
