Determine whether Bash resolves printf as an alias, function, builtin, or executable.
Show all same-name candidates, not only executables on PATH.
Which command is appropriate?
Bash type reports how a name is interpreted as a command. type -a shows all matching interpretations and PATH entries.
Detailed explanation
which printfIncorrect. which generally searches PATH and does not show aliases or functions reliably.
Incorrect. which generally searches PATH and does not show aliases or functions reliably.
whereis printfIncorrect. whereis searches standard filesystem locations rather than Bash's command resolution.
Incorrect. whereis searches standard filesystem locations rather than Bash's command resolution.
type -p printfIncorrect. type -p limits the result to executable PATH entries.
Incorrect. type -p limits the result to executable PATH entries.
type -a printfCorrect. type -a printf shows all interpretations and matching executables.
Correct. type -a printf shows all interpretations and matching executables.
Try it yourself
An example you can run in a temporary verification environment.
type -a printfExpected result
printf is a shell builtinに加え、存在すればPATH上の実行ファイルKey points
- Shell builtin
- Alias and function
- -a shows all candidates
Notes
- Environment: Bash 5.2
- 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.