Find out if a command exists on POSIX system

后端 未结 3 1601
执念已碎
执念已碎 2020-12-09 10:19

I want to be able to tell if a command exists on any POSIX system from a shell script.

On Linux, I can do the following:

if which ; th         


        
3条回答
  •  清歌不尽
    2020-12-09 10:52

    command -v is a POSIX specified command that does what which does.

    It is defined to to return >0 when the command is not found or an error occurs.

提交回复
热议问题