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