在csh脚本中,只有当某个命令可用时,我才需要执行某些操作。我想做一些像这样的事情
if( _WHAT_TO_PUT_HERE_ ) then # enter only if command "cmd" is in the path
cmd ...
endif如何在csh或tcsh中做到这一点?
发布于 2012-06-28 15:45:26
我想使用where命令可以解决您的问题
请检查以下内容:
~/animesh >where grep
/bin/grep
/tools/cfr/bin/grep
~/animesh >where egrep
/bin/egrep
/tools/cfr/bin/egrep
~/animesh >where xgrep
~/animesh >因此,假设您正在尝试查找一个名为my_cmd的命令,请尝试以下代码:
if(`where my_cmd` != "") then
my_cmd
endifhttps://stackoverflow.com/questions/11137577
复制相似问题