当前位置: 技术问答>linux和unix
linux shell编程的一个实际应用问题
来源: 互联网 发布时间:2015-06-28
本文导语: CHECKJAVA=$(grep JAVA_HOME ~/.bash_profile) echo $CHECKJAVA if [ ! CHECKJAVA = null ];then #如何判断java已经安装,我不知道就用了个null试试 echo "Java is already installed" echo "$CHECKJAVA" else echo "Java is not installed" fi 我要的结...
CHECKJAVA=$(grep JAVA_HOME ~/.bash_profile)
echo $CHECKJAVA
if [ ! CHECKJAVA = null ];then #如何判断java已经安装,我不知道就用了个null试试
echo "Java is already installed"
echo "$CHECKJAVA"
else
echo "Java is not installed"
fi
我要的结果是,当JAVA_HOME找到,则输出java已经安装,并显示找到的相关信息,没有找到则显示没有找到.
谢谢
echo $CHECKJAVA
if [ ! CHECKJAVA = null ];then #如何判断java已经安装,我不知道就用了个null试试
echo "Java is already installed"
echo "$CHECKJAVA"
else
echo "Java is not installed"
fi
我要的结果是,当JAVA_HOME找到,则输出java已经安装,并显示找到的相关信息,没有找到则显示没有找到.
谢谢
|
CHECKJAVA=$(grep JAVA_HOME ~/.bash_profile)
echo $CHECKJAVA
if [ "$CHECKJAVA" != "" ]; then
echo "Java is already installed"
echo "$CHECKJAVA"
else
echo "Java is not installed"
fi
echo $CHECKJAVA
if [ "$CHECKJAVA" != "" ]; then
echo "Java is already installed"
echo "$CHECKJAVA"
else
echo "Java is not installed"
fi
|
why not use :
if [ -n $JAVA_HOME ] ; then
echo "JAVA installed"
else
echo "Oops !"
fi
if [ -n $JAVA_HOME ] ; then
echo "JAVA installed"
else
echo "Oops !"
fi