type
Display information about command type.[1]
Documentation
- type [EN] @ GNU Bash Reference Manual
- bash -c 'help type'
- man 1 'bash' [EN]
Syntax
type [PARAMETER ...] NAME [NAME ...]
Parameters
- -a
- Display all locations containing an executable named NAME; includes aliases, builtins, and functions, if and only if the -p option is not also used.
- -f
- Suppress shell function lookup.
- -p
- Returns either the name of the disk file that would be executed, or nothing if type -t NAME would not return file.
- -P
- Force a PATH search for each NAME, even if it is an alias, builtin, or function, and returns the name of the disk file that would be executed.
- -t
- Output a single word which is one of alias, keyword, function, builtin, file or nothing, if NAME is an alias, shell reserved word, shell function, shell builtin, disk file, or not found, respectively.
Examples
- Test if a shell binary exists
if type -P "${bin}" >'/dev/null' 2>&1; then
echo "Binary '${bin}' exists"
else
echo "Binary '${bin}' does not exist"
fi
References
- ↑ bash -c 'help type'