Uso il comando whereis rm
$ whereis rm
/bin/rm
Quindi provo which rm
$ which rm
/usr/local/opt/coreutils/libexec/gnubin/rm
I risultati sono diversi... quindi quale rm verrà chiamato quando eseguo un comando come rm readme ?
Risposta accettata:
Questa risposta su Super User di Denilson Sá Maia può essere utile:
which cerca il PERCORSO specifico dell'utente (che può includere alcune delle posizioni in cui è ricercato e potrebbe non includerne altre – potrebbe anche includere alcuni luoghi che whereis non esegue la ricerca se l'hai aggiunto al PERCORSO).
whereis cerca nelle posizioni standard *nix un comando specificato.
$ whatis which
which (1) - shows the full path of (shell) commands
$ whatis whereis
whereis (1) - locate the binary, source, and manual page files for a command
Fondamentalmente, whereis cerca i file "possibilmente utili", mentre which cerca solo eseguibili.
Uso raramente whereis . D'altra parte, which è molto utile, specialmente negli script. which è la risposta alla seguente domanda:Da dove viene questo comando?
$ which ls
/bin/ls
$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.bz2 /usr/share/man/man1/ls.1.bz2