shell 编程入门1

今天小写了几个Shell绝对入门的命令,没想到尽然出错了。

#!/bin/bash

echo "Guess what's the color of my underware?"

read color

if [ $color="red" ]

then

    echo "you are right1"

fi

if的判断竟是无论如何都是真!晕了,

又改为

if [ $color=="red"]

then

if[$color="red"];then

都不行,最好改成

if [ $color  =  "red"  ] ; then

或者

if [ $color ==  "red"  ]

then

或者

if [  $color  =  "red"  ]

then

就可以了,一定要注意空格。

bash 新手指南:

http://xiaowang.net/bgb-cn/index.html

 

你可能感兴趣的:(html,编程,.net,bash)