Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

If the which command is not available, is there another 'standard' method to find out where a command's executable can be found?

If there is no other 'standard' method available, the actual system I face currently is a bare Android emulator with an ash Almquist shell, if that means anything.

share|improve this question

marked as duplicate by Gilles, slm, jasonwryan, Anthon, Thomas Nyman Apr 24 '14 at 9:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

@StephaneChazelas that may mean my question is a duplicate. I've tried to search for this question but I missed what you linked. thanks! – n611x007 Apr 23 '14 at 16:00
well, the other question is perhaps properly described with that all you never thought you would ever not want to know about it - this leaves some room for mine . :) – n611x007 Apr 23 '14 at 20:51
up vote 9 down vote accepted

This should be a standard solution:

type -t
type -p
share|improve this answer
you're right, it works, thank you, I forgot type. Is there a reference that declares it standard, by the way? like some document at opengroup. If there is, can you link it perhaps? – n611x007 Apr 23 '14 at 15:02
type and command -V/v are standard (Unix, LSB, but optional in POSIX (XSI), type -p and type -t are not. – Stéphane Chazelas Apr 23 '14 at 15:11


Not quite the same, but should give you the binary's location like 'which' does.

share|improve this answer
good to know, thanks, but it in the current OS it does not work for me – n611x007 Apr 23 '14 at 15:03

You can search the $PATH yourself to find a command:

COMMAND=vim # This is the command  to search for
(IFS=:; for dir in $PATH; do [ -x  $dir/$COMMAND ] && echo $dir/$COMMAND; done)

(this should work in ash and many other Bourne shell derivatives)

share|improve this answer
this is a good option if [ is included on the target system. – n611x007 Apr 23 '14 at 20:53
If your shell or keyboard doesn't support "[]" (I think ash does), you can replace [ -x $dir/$COMMAND ] with test -x $dir/$COMMAND (test is a bash/ash built-in, and may also be available as a standalone executable – Johnny Apr 23 '14 at 21:09
:) it's not actually my keyboard, my ash on this Android emulator seems not to come with either [ or test. I'm not sure if I'm doing anything wrong, the system seems stock and reports ash for shell. – n611x007 Apr 23 '14 at 21:22
I would regard any shell without either test or [...] as unusable for any but the most limited purposes. – iconoclast Nov 18 '14 at 0:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.