csh script: check if command exists

混江龙づ霸主 提交于 2019-12-02 09:15:38

问题


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



来源:https://stackoverflow.com/questions/22040308/csh-script-check-if-command-exists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!