I think most are familiar with the which command, and I use it frequently. I just ran into a situation where I'm curious not just which command is first in my path, but how many and where all the commands in all my paths are. I tried the which man page (typing man which made me laugh), but didn't see anything.
`which`, but all
path
On some systems, which -a shows all matches. If your shell is bash or zsh, you can use type instead: type foo shows the first match and type -a foo shows all matches. The three commands type, which and whence do mostly the same thing; they differ between shells and operating systems in availability, options, and what exactly they report. type is always available and shows all possible command-like names (aliases, keywords, shell built-ins, functions, and external commands).The only fully portable way to display all matches is to parse $PATH yourself. Here's a shell script that does this. If you make it a shell function, make sure to enclose the function body in parentheses (so that the change to IFS and set -f don't escape the function), and change exit to return.#!/bin/shset -f       # disable globbingIFS=:        # break words at : onlynot_found=1for d in $PATH; do  if [ -f $d/$x ] && [ -x $d/$x ]; then    printf '%s\n' $d/$x    not_found=0  fidoneexit $not_found Or ksh 93, according to the documentation, though ksh 93s+ 2008-01-31 only prints the first match when I try.