Skip to content
Latchkey

xargs -p: Prompt Before Each Command

xargs -p prints each command and waits for a yes/no answer before running it.

For destructive bulk actions at an interactive shell, -p lets you confirm each command. It is the opposite of what you want inside a pipeline.

What it does

xargs -p (interactive) echoes each command line, like -t, then reads from the terminal and runs the command only if the response starts with y. It implies -t. It is designed for a human at a TTY reviewing a destructive operation before it executes.

Common usage

Terminal
# review each deletion before it happens
find . -name '*.bak' | xargs -p rm
ls *.iso | xargs -p -n 1 rm

Options

FlagWhat it does
-pPrompt before each command and run only on y
(implies -t)Also echoes the command being confirmed
(reads /dev/tty)Reads the answer from the terminal, not stdin
(answer y/Y)Any other answer skips that command

In CI

Never use -p in a pipeline. CI runners have no interactive terminal, so the prompt has no one to answer it; depending on the implementation the step hangs until timeout or every command is skipped because the read returns empty. Use -t for visibility and a separate review step for safety.

Common errors in CI

In a runner -p typically causes the job to hang at "...?..." waiting for input until the build times out, or it silently skips every command (so nothing happens and the step "passes" doing no work). If you want a record without prompts, switch to -t. To preview, prefix the command with echo.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →