csh 脚本:检查命令是否存在 [英] csh script: check if command exists

查看:12
本文介绍了csh 脚本:检查命令是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要这样的东西

如果(command_not_exists)退出

谁能告诉我如何在 cshell 脚本中实现这个功能?

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

推荐答案

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

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

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

谢谢

这篇关于csh 脚本:检查命令是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆