如何比较unix中的用户输入

时间:2014-12-08 16:08:08

标签: bash shell unix

#!/bin/bash
echo "Whats your name ?"
read NAME

if [$NAME == "SSJ" ]
then
  echo "Welcome back SSJ"
fi

2 个答案:

答案 0 :(得分:2)

这样做:

#!/bin/bash
echo "Whats your name ?"
read name

if [ "$name" = "SSJ" ]
then
  echo "Welcome back SSJ"
fi

答案 1 :(得分:0)

试试这个:

#!/bin/bash
echo "Whats your name ?"
read NAME

if [ "$NAME" == "SSJ" ]; then
  echo "Welcome back SSJ"
fi