Whence and WhencemanWednesday, 31 Mar 2010 11:17:52 · 1 minute read · Comments
On the UNIX command line, the `which` command is great, it tells you where a command is in the system. However, if your system has two versions of the `ls` command, it will only tell you which `ls` command you are going to use when tap it in and press enter. To find all copies of any command, we need something Liam called `whence` (I inherited Liam’s bashrc file when working at Sun, and this little gem was right inside it). The .bashrc function for `whence` looks something like this:
It’s nice and straightforward, nothing complicated about it at all. In fact, to let everyone on your system use it, you could just stick “#!/bin/sh” at the top and stick in a file in /usr/bin !
Today, I wanted to find a man page, the sysidcfg man page to be precise. Instead of doing the usual trick (`find / | grep sysidcfg"), I thought I’d modify `whence` to look for it for me, and seeing as it’s no longer `whence`, I called it `whenceman`:
As you can see, it’s very similar, and you could do the same thing by putting it in /usr/bin so everyone could use it.