#!/bin/shshell
echo -n "login:"ide
read namepost
echo -n "password:"spa
read passwdci
if [ "$name" = "aa" -a "$passwd" = "aaa" ];thenpostmessage
echo "right!"it
else echo "error"table
ficlass
一。運行過程當中出現過 [: missing `]' 的問題,是[ "$name" = "aa" -a "$passwd" = "aaa" ] "$name"前和"aaa"後都必需要有空格。語法
二。if裏面的-a至關因而與,-o至關因而或。還能夠用&&和||表達。
if [ "$name" = "aa" -a "$passwd" = "aaa" ];then 與
if [ "$name" = "aa" -o "$passwd" = "aaa" ];then 或
if [ "$name" = "aa" ] && [ "$passwd" = "aaa" ];then 與
if [ "$name" = "aa" ] || [ "$passwd" = "aaa" ];then 或
&&是shell自己的語法支持-a是shell的內部指令的用法 |