-->

csh script: check if command exists

2020-04-21 02:32发布

问题:

I would like to have something like this

if (command_not_exists) exit

Can someone tell me how to achieve this functionality in a cshell script?

回答1:

My problem is solved using where command (I was trying with which command). Solution:

   if(`where test_cmd` == "") then
      printf "\ntest_cmd: Command not found\n";
      exit(1);
   endif

Thanks