注册 登录
编程论坛 Linux教室

一个简单的shell程序,不知为什么错了

流水e梦 发布于 2010-10-30 23:29, 938 次点击
#! /bin/bash
#a function of
 echo "P: To display current directory"
 echo "S: To display the name of running file"
 echo "D: To display today's date and present time"
 echo "L: To see the listing of files in your working directory"
 echo "W: To see who is logged in"
 echo "Q: To quit this program"
 echo "Enter your option and hit:"
 read char
 until [$char = 'Q']
 do
# echo "Enter your option and hit:"
# read char
 case $char in
 P|p) pwd
 ;;
 S|s) ps
 ;;
 D|d) date
 ;;
 L|l) ls
 ;;
 W|w) who
 ;;
 *) echo "Please input a correct command!"
 esac
 echo "Enter your option and hit:"
 read char
 done

其中 until [$char = 'Q']错在哪,麻烦解释清楚
6 回复
#2
lucky5635912010-11-04 07:57
原来shell也有编程,还没学语法规则
#3
dqb1990aion2010-11-12 15:51
其中 until [$char = 'Q']错在哪,麻烦解释清楚


正确应该是: until [$char = ‘Q']
#4
oscillator2010-11-15 13:39
以下是引用dqb1990aion在2010-11-12 15:51:03的发言:

其中 until [$char = 'Q']错在哪,麻烦解释清楚


正确应该是: until [$char = ‘Q']
那个,我怎么看不出这两个有什么区别呀?
#5
pangding2010-11-25 19:09
[ 是个命令,前后要用空格分开。你查一下手册就知道了。
#6
viky20032011-01-19 20:43
test 与[ ]的用法,用test就不会不小心错了
#7
vfdff2011-03-08 23:47
是的,shell中特别注意空格
1