+ -
当前位置:首页 → 问答吧 → 新人求助,shell脚本怎么执行啊?

新人求助,shell脚本怎么执行啊?

时间:2011-10-21

来源:互联网

代码:
#! /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的判断条件有错,不知道正确的格式应该怎么样

作者: Mr沛   发布时间: 2011-10-21

空格啊空格。。。。
代码: [ 下载 ] [ 隐藏 ]
代码: [ 下载 ] [ 显示 ]
使用 bash 语法高亮
[ "$opt" = "x" ]
 
格式化 0.009 秒, 使用 GeSHi 1.0.8.4

[ 是程序名,后面四项都是它的参数。

作者: lilydjwg   发布时间: 2011-10-21