当前位置:网站首页>Condition judgment
Condition judgment
2022-07-22 21:26:00 【Ten at eight】
1、 Judge according to the document type ( Red ink is the main common command )
Test options | effect |
-b file | Determine if the file exists , And whether it is a block device file ( It's a block of device files that are true ) |
-c file | Determine if the file exists , And whether it is a character device file ( Is the character device file true ) |
-d file | Determine if the file exists , And whether it is a directory file |
-e file | Determine if the file exists |
-f file | Determine if the file exists , And whether it's a normal document |
-L file | Determine if the file exists , And whether it is a symbolic link file |
-p file | Determine if the file exists , And whether it's a pipeline file |
-s file | Determine if the file exists , And whether it is non empty |
-S file | Determine if the file exists , And is it a socket file |
2、 Judge according to the file authority
Test options | effect |
-r file | Determine if the file exists , And whether the file has read permission |
-w file | Determine if the file exists , And whether the file has write permission |
-x file | Determine if the file exists , And whether the file has execution permission |
-u file | Determine if the file exists , And whether the file owns SUID jurisdiction |
-g file | Determine if the file exists , And whether the file owns SGID jurisdiction |
-k file | Determine if the file exists , And whether the file owns SBit jurisdiction |
3、 Compare the two files
Test options | effect |
file 1 -nt file 2 | Judge documents 1 Whether the modification time of the file is longer than 2 The new ( New is true ) |
file 1 -ot file 2 | Judge documents 1 Whether the modification of is better than that of the file 2 The old ( Old is true ) |
file 1 -ef file 2 | Judge documents 1 Whether or not to file 2 Of Inode No , It can be understood as whether two files are the same file . This judgment is a good way to judge hard links . |
4、 Compare two integers
Test options | effect |
Integers 1 -eq Integers 2 | Judgement integer 1 Whether or not and integers 2 equal ( Equality is true ) |
Integers 1 -ne Integers 2 | Judgement integer 1 Whether or not and integers 2 It's not equal ( Inequality is true ) |
Integers 1 -gt Integers 2 | Judgement integer 1 Is it greater than an integer 2( Greater than is true ) |
Integers 1 -lt Integers 2 | Judgement integer 1 Is it less than an integer 2( Less than is true ) |
Integers 1 -ge Integers 2 | Judgement integer 1 Whether it is greater than or equal to an integer 2( Greater than or equal to true ) |
Integers 1 -le Integers 2 | Judgement integer 1 Is it less than or equal to an integer 2( Less than or equal to true ) |
5、 String judgment
Test options | effect |
-z character string | Determines if the string is empty ( Empty is true ) |
-n character string | Determine whether the string is non empty ( Not empty is true ) |
character string 1 == character string 2 | Judgment string 1 And 2 Whether it is equal or not ( Equality is true ) |
character string 1 != character string 2 | Judgment string 1 And 2 Is it unequal ( Inequality is true ) |
6、 Multiple condition judgment
Test options | effect |
Judge 1 -a Judge 2 | Logic and , Judge 1 And judgment 2 All set up , The result returns true |
Judge 1 -o Judge 2 | Logic or , Judge 1 And judgment 2 There is a foundation , The result returns true |
! Judge | Logic is not , Reverse the original judgment |
边栏推荐
- Chapter 4: Minio's pre signed URLs upload files
- NSSCTF-01-[SWPUCTF 2021 新生赛]gift_F12
- Bishett route - hyperspectral image classification with deep learning in pytorch environment
- [lttng learning journey] - trace control -- advanced
- Bash basic functions alias and shortcut keys
- 第四章:minio的presigned URLs上传文件
- [LTTng学习之旅]------LTTng的Feature
- How to do research and development lean demand management well
- mysql 连接查询在on中使用convert 导致扫描行数增长
- BUUCTF闯关日记--[极客大挑战 2019]HardSQL1
猜你喜欢
随机推荐
Seata 初识
Pytorch自动求导
2020中南大学信息与通信夏令营面试
[lttng learning journey] - trace control - Preliminary
BUUCTF闯关日记--[网鼎杯 2020 青龙组]AreUSerialz
Interview shock 67: talk about tcp/ip protocol? And the role of each layer?
Buuctf entry diary -- [nctf2019]fake XML Cookbook
使用简单的js实现圆弧布局
第二章:给项目配置数据源,redis,security,swagger等工具jar
Bash基本功能—别名与快捷键
Set colSpan invalidation for TD of table
第四章:minio的presigned URLs上传文件
Juc-6.3-concurrency container queue
JS BOM(浏览器对象模型)
[lttng learning journey] - before starting
Bash基本功能—输入输出重定向
TIME的新封面:元宇宙将改变一切
Chapter 2: configure data sources, redis, security, swagger and other tools jar for the project
Buuctf breakthrough diary 03 -- [geek challenge 2019] havefun1
Chapter 2: Minio stand-alone version, using the client to back up files