|The stupid question is the question not asked|
Re: How to find whether an external commands existsby december (Pilgrim)
|on May 04, 2009 at 09:02 UTC||Need Help??|
Using 'which' or the path as suggested elsewhere in this thread are definitely ways to get what you want.
You could just check if the file exists and is executable:
tar(1) and rm(1) should be in /bin on pretty much any Unix system, so you could get away without checking the path (at least for the commands you listed).
If I remember correctly, some incarnations of Unix allow executable files to be effectively unreadable, so it might be best to check for existence and "executability", and not readability.
Another way is to execute the command with an argument of --version or --help, this way you are sure the command executes. You don't need to actually provide any files or do something, such as tar'ing a directory. At least all common GNU programs should accept the version/help arguments, but try it for the specific commands you want to use.