linux shell 中判断字符串为空的正确方法
来源:互联网 发布:零基础学java pdf 编辑:程序博客网 时间:2024/06/06 08:46
help命令可以查看帮助
help test
正确做法:
#!/bin/sh
STRING=
if [ -z "$STRING" ]; then
echo "STRING is empty"
fi
if [ -n "$STRING" ]; then
echo "STRING is not empty"
fi
root@james-desktop:~# ./zerostring.sh
STRING is empty
-------------------------------------------------------------------------
错误做法:
#!/bin/sh
STRING=
if [ -z $STRING ]; then
echo "STRING is empty"
fi
if [ -n $STRING ]; then
echo "STRING is not empty"
fi
输出错误结果:
root@james-desktop:~# ./zerostring.sh
STRING is empty
STRING is not empty
0 0
- linux shell 中判断字符串为空的正确方法
- linux shell 中判断字符串为空的正确方法
- shell中判断字符串为空的几种方法
- iOS中判断字符串是否为空字符串的方法
- linux shell 判断空字符串的几种方法!
- Linux shell 中判断一个变量是否为空 的方法
- shell判断字符串为空
- shell判断字符串为空
- IOS中判断字符串是否为空的方法
- shell中判断空字符串和有趣的空字符串
- 判断字符串是否为空的方法
- 判断字符串是否为空的方法
- IOS 判断字符串为空的方法
- 判断字符串为空的方法
- 判断字符串为空的方法
- java判断字符串为空的方法
- 判断字符串是否为空的方法
- 判断字符串为空的方法详解
- 把数组排成最小的数
- notifation消息栏通知遇到的问题——
- Android Studio无法创建新的Activity报出ide internal error occurred错
- UVa 10305 Ordering Tasks 拓扑排序
- 二进制分流法
- linux shell 中判断字符串为空的正确方法
- C&C++编译过程
- Android学习基础之onSaveInstanceState和onRestoreInstanceState触发的时机
- OC关联objc_setAssociatedObject
- [leetcode] 327. Count of Range Sum 解题报告
- 自己写的java邮件客户端
- 第8周项目3 - 指向学生类的指针
- javasript dom 中获取元素类名 或者 改变类 引用另外一个类
- 决策树介绍一