linux 命令 之判断表达式
摘自http://www.comptechdoc.org/os/linux/usersguide/linux_ugshellpro.html
Tests
There is a function provided by bash called test which returns a true or false value depending on the result of the tested expression. Its syntax is:
test expression
It can also be implied as follows:
[ expression ]
The tests below are test conditions provided by the shell:
- -b file = True if the file exists and is block special file.
- -c file = True if the file exists and is character special file.
- -d file = True if the file exists and is a directory.
- -e file = True if the file exists.
- -f file = True if the file exists and is a regular file
- -g file = True if the file exists and the set-group-id bit is set.
- -k file = True if the files' "sticky" bit is set.
- -L file = True if the file exists and is a symbolic link.
- -p file = True if the file exists and is a named pipe.
- -r file = True if the file exists and is readable.
- -s file = True if the file exists and its size is greater than zero.
- -s file = True if the file exists and is a socket.
- -t fd = True if the file descriptor is opened on a terminal.
- -u file = True if the file exists and its set-user-id bit is set.
- -w file = True if the file exists and is writable.
- -x file = True if the file exists and is executable.
- -O file = True if the file exists and is owned by the effective user id.
- -G file = True if the file exists and is owned by the effective group id.
- file1 –nt file2 = True if file1 is newer, by modification date, than file2.
- file1 ot file2 = True if file1 is older than file2.
- file1 ef file2 = True if file1 and file2 have the same device and inode numbers.
- -z string = True if the length of the string is 0.
- -n string = True if the length of the string is non-zero.
- string1 = string2 = True if the strings are equal.
- string1 != string2 = True if the strings are not equal.
- !expr = True if the expr evaluates to false.
- expr1 –a expr2 = True if both expr1 and expr2 are true.
- expr1 –o expr2 = True is either expr1 or expr2 is true.
linux 命令 之判断表达式的更多相关文章
- Linux 命令小记
1. pidof 进程名 :获取进程的pid,例如 pidof memcached 得到5333 2. unset Shell变量 :取消设置一个shell变量,从内存和shell的导出环境中删除它, ...
- LINUX命令总结 -------来自 水滴娃娃 的CSDN
LINUX命令总结 标签: LINUX命令总结 2014-01-27 15:54 41039人阅读 评论(1) 收藏 举报 分类: linux(1) 版权声明:本文为博主原创文章,未经博主允许不得 ...
- Linux命令自己总结
对于每一个Linux学习者来说,了解Linux文件系统的目录结构,是学好Linux的至关重要的一步.,深入了解linux文件目录结构的标准和每个目录的详细功能,对于我们用好linux系统只管重要,下面 ...
- 嵌入式开发应该掌握的一些Linux命令
Linux提供了大量的命令,利用它可以有效地完成大量的工作,如磁盘操作.文件存取.目录操作.进程管理.文件权限设定等.所以,在Linux系统上工作离不开使用系统提供的命令.要想真正理解Linux系统, ...
- linux 命令总结(转载)
linux 命令总结(转载) 1. 永久更改ip ifconfig eth0 新ip 然后编辑/etc/sysconfig/network-scripts/ifcfg-eth0,修改ip 2.从Lin ...
- 来聊一聊不low的Linux命令——find、grep、awk、sed
前几天面试,被一位面试官嫌弃了"你的Linux命令有点low".被嫌弃也挺正常的,因为我的简历写的我自己都有点看不下去:了解Linux常用命令,如ls,tail -f等命令,基本满 ...
- 工作中常用的 Linux 命令
awk 示例: env变量值如下,需要获得pkg_url的链接值: {"name": "michael", "sex": "mal ...
- Linux命令行文本工具
浏览文件 cat 查看文件内容 more 以翻页形式查看文件内容(只能向下翻页) less 以翻页形式查看文件内容(可以上下翻页) head 查看文件的头几行(默认10行) tail 查看文件的尾几行 ...
- [转帖]Linux命令中特殊符号
Linux命令中特殊符号 转自:http://blog.chinaunix.net/uid-16946891-id-5088144.html 在shell中常用的特殊符号罗列如下:# ; ;; . ...
随机推荐
- ubuntu 14.04 配置tomacat8
自己在虚拟机总安装tomcat8,主机访问,记下步骤方便以后查看. 1.将tomcat8安装包移动到/usr/local目录中(个人喜欢把自己安装的软件放到/usr/local文件夹中) 2.解压缩, ...
- Warning: strftime(): It is not safe to rely on the system's timezone settings.
当运行程序时,会出现如下警告: Warning: strftime(): It is not safe to rely on the system's timezone settings. You a ...
- dubbo/dubbox 增加原生thrift及avro支持
(facebook) thrift / (hadoop) avro / (google) probuf(grpc)是近几年来比较抢眼的高效序列化/rpc框架,dubbo框架虽然有thrift的支持,但 ...
- [LeetCode] Kth Smallest Element in a Sorted Matrix 有序矩阵中第K小的元素
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth ...
- 使用Xcode7的Instruments检测解决iOS内存泄露
文/笨笨的糯糯(简书作者)原文链接:http://www.jianshu.com/p/0837331875f0著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”. 作为一名iOS开发攻城狮, ...
- virtualenv 安装使用
不同的人喜欢用不同的方式建立各自的开发环境,但在几乎所有的编程社区,总有一个(或一个以上)开发环境让人更容易接受. 使用不同的开发环境虽然没有什么错误,但有些环境设置更容易进行便利的测试,并做一些 ...
- ubuntu中pycharm安装激活第二种方法的密钥
43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0M0I0QTczWVlKIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYXNza WduZWVOYW1lIjoi ...
- JavaScript零基础学习系列五
定时器 1.定时器:设定时间,在指定的时间之后执行函数或者是程序 a.反复性定时器:var dingshiqi=Window.setInterval("函数名()",时间n[毫 ...
- BZOJ 1221: [HNOI2001] 软件开发
1221: [HNOI2001] 软件开发 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1428 Solved: 791[Submit][Stat ...
- Javascript字节转换
//文件大小转换 function bytesToSize(bytes) { if (bytes === 0) return '0 B'; var k = 1024; sizes = ['B', 'K ...