Search code examples
commandwhere-clausecsh

csh script: check if command exists


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?


Solution

  • 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