我想查看系统是否安装了nodejs。我收到此错误:
Error : command not found.
我该如何解决?
#!/bin/bash
if [ nodejs -v ]; then
echo "nodejs found"
else
echo "nodejs not found"
fi
最佳答案
您可以使用 command
bash builtin :
if command -v nodejs >/dev/null 2>&1 ; then
echo "nodejs found"
echo "version: $(nodejs -v)"
else
echo "nodejs not found"
fi
关于linux - 如何检查 bash 脚本中的依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33297857/