Inspect commands already run in the current interactive Bash session.
Display them together with history numbers.
Which shell builtin should be used?
The Bash history builtin prints the current history list with its numbers, which helps locate commands for review or reuse.
Detailed explanation
manIncorrect. man displays manual pages and does not list session history.
historyCorrect. history prints the loaded history list with numbers.
envIncorrect. env displays environment variables.
pwdIncorrect. pwd displays the current working directory.
Try it yourself
An example you can run in a temporary verification environment.
bash -ic 'history -s "printf demo"; history 1' 2>/dev/nullExpected result
履歴番号とprintf demoを含む1行Key points
- history is a shell builtin
- The list has history numbers
- It is used in interactive shells
Notes
- Environment: Bash 5.x / 一時的な対話シェル
- Use disposable shell sessions and harmless commands for experiments.
- Shell behavior can depend on Bash options and distribution defaults.
Foundation review
Place the operation
The history builtin prints command lines and their event numbers from the current session.
Check the side effect
Remember that history visibility and persistence depend on the shell and its configuration.