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中常用的特殊符号罗列如下:# ; ;; . ...
随机推荐
- Eclipse注释模板设置详解
设置注释模板的入口:Window->Preference->Java->Code Style->Code Template 然后展开Comments节点就是所有需设置注释的元素 ...
- Don't repeat yourself
今天工作上要测试不同版本mysql在不同系统的速度,学习了怎么源码安装mysql后,就开始敲命令安装和编译执行测试程序. 这么走了两遍后,想起一句话——当一件事重复做三遍后,要考虑把它工具化,自动化. ...
- NFS指定端口
nfs服务端: 编辑/etc/nfsmount.conf,在末尾添加: RQUOTAD_PORT=30001LOCKD_TCPPORT=30002LOCKD_UDPPORT=30002MOUNTD_P ...
- BZOJ3160万径人踪灭
Description Input & Output & Sample Input & Sample Output HINT 题解: 题意即求不连续但间隔长度对称的回文串个数. ...
- Node6.9.2 —— Http官网笔记整理
欢迎指导与讨论 : ) 序章 本文概要:http.Agent代理.http.ClientRequest客户端请求.http.server服务器.http.ServerResponse服务器相应.htt ...
- linux系统top命令查看系统状态
Linux系统可以通过top命令查看系统的CPU.内存.运行时间.交换分区.执行的线程等信息.通过top命令可以有效的发现系统的缺陷出在哪里.是内存不够.CPU处理能力不够.IO读写过高. 使用SSH ...
- [LeetCode] Valid Word Abbreviation 验证单词缩写
Given a non-empty string s and an abbreviation abbr, return whether the string matches with the give ...
- 【C#】调度程序进程已挂起,但消息仍在处理中;
环境:WPF.弹窗,messageBox.show();错误信息:调度程序进程已挂起,但消息仍在处理中:解决方法:Dispatcher.BeginInvoke(new Action(()=>{ ...
- 关于Django 错误 doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
记录一下 报错 doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS\ 这个问题出现没 ...
- java为什么非静态内部类中不能有static修饰的属性,但却可以有常量?
如:public class InnerClassDemo{int x;class A{static int a = 0;//这样写是不合法的.static final int b=0;//这样写是合 ...