type

type toont hoe de shell een commando interpreteert — alias, ingebouwde functie, functie of extern programma.

Basisgebruik

type ls
type cd
type echo

Uitvoer

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

Opties

OptieBetekenis
-aToon alle vindplaatsen
-tAlleen het type (alias, builtin, function, file)
-PAlleen het pad (zoals which)

Voorbeelden

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

Tip

type is betrouwbaarder dan which voor het detecteren van aliassen en ingebouwde commando's — which vindt alleen externe programma's.

shell