C'est quoi, which ?
which affiche le chemin complet de la commande qui sera exécutée quand tu tapes son nom. Utile pour savoir quelle version d'un programme est active ou si un programme est installé.
💡 L'analogie : which, c'est comme demander "où exactement vit ce programme sur mon système ?"
# Où est python3 ?
$ which python3
/usr/bin/python3
# Vérifier si un programme est installé
$ which docker
/usr/bin/docker
# Programme non installé
$ which htop
htop not found
# Toutes les occurrences (-a)
$ which -a python
/usr/bin/python
/usr/local/bin/python
# Dans un script : tester si installé
if ! which docker &> /dev/null; then
echo "Docker n'est pas installé"
fi