Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 csh 脚本中,只有当某个命令可用时,我才需要执行某些操作。我想做类似的事情
if( _WHAT_TO_PUT_HERE_ ) then # enter only if command "cmd" is in the path cmd ... endif
如何在 csh 或 tcsh 中做到这一点?
我想使用 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 endif