printf may be a shell builtin and an external executable.
List every resolution Bash can use for the name.
Which command is appropriate?
Bash type identifies command kinds and type -a lists every matching resolution, including builtins and PATH entries.
Detailed explanation
which printfIncorrect. which normally searches PATH and may omit shell builtins and alternate resolutions.
Incorrect. which normally searches PATH and may omit shell builtins and alternate resolutions.
command -v printfIncorrect. command -v reports one resolution, not all of them.
Incorrect. command -v reports one resolution, not all of them.
whereis printfIncorrect. whereis searches files and manuals rather than Bash's full resolution order.
Incorrect. whereis searches files and manuals rather than Bash's full resolution order.
type -a printfCorrect. type -a lists all resolutions known to Bash.
Correct. type -a lists all resolutions known to Bash.
Try it yourself
An example you can run in a temporary verification environment.
type -a printf
command -v printfExpected result
type -a: printf is a shell builtin と外部printfのパス
command -v: printf
※文言と外部コマンドのパスは環境により異なるKey points
- Bash builtins versus external commands
- type -a
- Why which is incomplete
Notes
- Environment: Bash 5.2 / GNU coreutils 9.x
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.