bash脚本中while的判断条件不能成立

sh/bash/dash/ksh/zsh等Shell脚本
回复
Mr沛
帖子: 5
注册时间: 2011-10-21 12:41

bash脚本中while的判断条件不能成立

#1

帖子 Mr沛 » 2011-10-21 12:46

代码: 全选

#! /bin/bash
opt="z"
until ["$opt"="x"];
do
        echo "a. List all files in the present working directory"
        echo "b. Display today's date and time, and your Linux version"
        echo "c. Invoke the shell script of Problem 2"
        echo "d. Display whether a file is a \"simple\" file or a \"directory\""
        echo "e. Create a backup for a file"
        echo "f. Start an ftp session to our course site"
        echo "x. Exit"
        echo "Please enter an option:"
        read opt
done
        echo "Bye-Bye"
就想做一个选项选择,运行的时候提示如下

代码: 全选

./work1: 行 4: [z=x]: 未找到命令
a. List all files in the present working directory
b. Display today's date and time, and your Linux version
c. Invoke the shell script of Problem 2
d. Display whether a file is a "simple" file or a "directory"
e. Create a backup for a file
f. Start an ftp session to our course site
x. Exit
Please enter an option:
会有一个这个

代码: 全选

./work1: 行 4: [z=x]: 未找到命令
我觉得应该是while的判断条件有错,不知道正确的格式应该怎么样
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: bash脚本中while的判断条件不能成立

#2

帖子 lilydjwg » 2011-10-21 13:10

空格啊空格。。。。
[bash]
[ "$opt" = "x" ]
[/bash]
[ 是程序名,后面四项都是它的参数。
Mr沛
帖子: 5
注册时间: 2011-10-21 12:41

Re: bash脚本中while的判断条件不能成立

#3

帖子 Mr沛 » 2011-10-21 13:19

lilydjwg 写了:空格啊空格。。。。
[bash]
[ "$opt" = "x" ]
[/bash]
[ 是程序名,后面四项都是它的参数。
哦,非常感谢 :em05
回复