csh 脚本:检查命令是否存在

Blu*_*Vio 2 command csh where-clause

我想要这样的东西

if (command_not_exists) exit

有人可以告诉我如何在cshell脚本中实现此功能吗?

Blu*_*Vio 5

我的问题是使用where命令解决的(我正在尝试使用which命令)。解决方案:

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

谢谢