type toont hoe de shell een commando interpreteert — alias, ingebouwde functie, functie of extern programma.
type ls
type cd
type echo
type ls
# ls is aliased to `ls --color=auto`
type cd
# cd is a shell builtin
type python3
# python3 is /usr/bin/python3
type mijnfunctie
# mijnfunctie is a function
| Optie | Betekenis |
|---|---|
-a | Toon alle vindplaatsen |
-t | Alleen het type (alias, builtin, function, file) |
-P | Alleen het pad (zoals which) |
Alles over een commando:
type -a python3
# python3 is /usr/bin/python3
# python3 is /usr/local/bin/python3
Alleen het type (handig in scripts):
type -t ls
# alias
type -t cd
# builtin
Controleren of commando beschikbaar is:
if type -t docker &>/dev/null; then
echo "Docker is beschikbaar"
fi
type is betrouwbaarder dan which voor het detecteren van aliassen en ingebouwde commando's — which vindt alleen externe programma's.