10

I'm just curious to know how to best check if a program exists. I've seen solutions with

  • test
  • command
  • hash
  • type
  • which
  • [

Which is the best method, is there a right answer? What does the POSIX and LSB specs say about this?

0

1 Answer 1

13

You probably want to use the command command, e.g.:

command -v <the_command>

For more discussion see the following StackOverflow posts:

Also see the following Unix StackExchange post:

2
  • Thanks but this a dupe of this, unix.stackexchange.com/questions/85249/… Commented Nov 13, 2017 at 3:23
  • @EvanCarroll Yeah, I just saw that. Well... problem solved! Commented Nov 13, 2017 at 3:24

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.