This question already has an answer here:
- Why not use “which”? What to use then? 3 answers
I want to check if a given command exists in
bash and I care only about the native commands of the bash and not the scripts written by the user. When I refer to
native commands I mean all those commands that are generally available to a user.
There are two commands
command -v type
that can be used to check if the command exists. But it also returns a true for user written scripts whereas I want to restrict myself just to the inbuilt commands.
Note: I am not just trying to distinguish between a
bash builtin and other commands because
type -t touch
file as the type, but this is a command available to the user by default. But if the user writes a script and then tries to run it then I would like to filter that.
Any help is appreciated.