#!/bin/bash missing() { echo $1 is missing 1>&2 return 127 } RAR=`type -P rar || echo missing rar` UNRAR=`type -P unrar|| echo missing unrar`
Use $ RAR or $ UNRAR in your script ... to do something. if they are absent, then the script will repeat that the command is absent
return 127 ensures that if you use the condition statement, it will fail if there are no files.
source share