设为首页
收藏本站
用户名
Email
自动登录
找回密码
密码
登录
注册
快捷导航
平台
Portal
论坛
BBS
文库
项目
群组
Group
我的博客
Space
搜索
搜索
热搜:
shell
linux
mysql
本版
用户
LinuxSir.cn,穿越时空的Linuxsir!
»
论坛
›
Linux 综合讨论区 —— LinuxSir.cn
›
shell进阶应用、shell编程
›
test 语法问题
返回列表
查看:
736
|
回复:
7
test 语法问题
[复制链接]
cx6445
cx6445
当前离线
积分
414
IP卡
狗仔卡
发表于 2003-9-5 20:39:32
|
显示全部楼层
|
阅读模式
#!/bin/bash
echo -n "Do you want to continue(y/n):"
read answer
if [ $answer=Y -o $answer=y ]
then
echo $answer
fi
为什么answer的值无论为什么,if 后面的 EXPRESSION 永远为真?
回复
使用道具
举报
提升卡
置顶卡
沉默卡
喧嚣卡
变色卡
显身卡
cx6445
cx6445
当前离线
积分
414
IP卡
狗仔卡
楼主
|
发表于 2003-9-5 21:59:25
|
显示全部楼层
已解决,=号左右要留下空格
回复
支持
反对
使用道具
举报
显身卡
Yuri
Yuri
当前离线
积分
3231
IP卡
狗仔卡
发表于 2005-6-6 14:10:53
|
显示全部楼层
我想问一下,如果要判断 $answer是否为空呢?
回复
支持
反对
使用道具
举报
显身卡
cx6445
cx6445
当前离线
积分
414
IP卡
狗仔卡
楼主
|
发表于 2005-6-6 14:18:22
|
显示全部楼层
-z $var
回复
支持
反对
使用道具
举报
显身卡
Yuri
Yuri
当前离线
积分
3231
IP卡
狗仔卡
发表于 2005-6-6 14:20:45
|
显示全部楼层
if [ -z $answer ]
then
echo "answer is null"
fi
复制代码
对吗?
回复
支持
反对
使用道具
举报
显身卡
kiron
kiron
当前离线
积分
1261
IP卡
狗仔卡
发表于 2005-6-6 17:57:16
|
显示全部楼层
Post by
genv
if [ -z $answer ]
then
echo "answer is null"
fi
复制代码
对吗?
try~~ ;)
回复
支持
反对
使用道具
举报
显身卡
crquan
crquan
当前离线
积分
284
IP卡
狗仔卡
发表于 2005-6-7 01:17:43
|
显示全部楼层
这是我见的最多的一种:
if [ "x$answer" != "x" ]; then
echo "\$answer is not null"
fi
复制代码
回复
支持
反对
使用道具
举报
显身卡
Yuri
Yuri
当前离线
积分
3231
IP卡
狗仔卡
发表于 2005-6-7 10:43:10
|
显示全部楼层
哦明白了~
回复
支持
反对
使用道具
举报
显身卡
返回列表
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
注册
本版积分规则
发表回复
回帖后跳转到最后一页
浏览过的版块
服务器架设、应用、维护
LFS(LinuxfromScratch)
Linux 输入开发与研究
Debian Linux
Redhat/Fedora/CentOS Linux
SuSE Linux
BSD 讨论专题
Archlinux讨论区
硬件设备 Linux 驱动
Gentoo Linux
Copyright © 2002-2023
LinuxSir.cn
(http://www.linuxsir.cn/) 版权所有 All Rights Reserved.
Powered by
RedflagLinux!
技术支持:
中科红旗
|
京ICP备19024520号
快速回复
返回顶部
返回列表