当前位置:网站首页>(6) Test command
(6) Test command
2022-07-19 01:30:00 【Hungry Taibai Xingjun】
#!/bin/bash
# Used to check whether the condition is true : The number 、 Characters and files
# ( One ) The number
:<<EOF
-eq Equal is true
-ne True if not equal
-gt Greater than is true
-ge True if greater than or equal to
-lt Less than is true
-le True if less than or equal to
EOF
num1=100
num2=200
if test ${
num1} -eq ${
num2}
then
echo Two numbers are equal
else
echo Two numbers are not equal
fi
# (1) In code [] Perform basic arithmetic operations , But it's best to use (())
echo "(num1+num2)*num1=$(((num1+num2)*num1))"
# (2)test You can use [] Instead of ,[] A space is required before and after the inside
if [ ${
num1} -eq ${
num2} ]
then
echo Two numbers are equal xxxx
else
echo Two numbers are not equal xxxx
fi
# ( Two ) String test
:<<EOF
= # Equality is true
!= # Inequality is true
-z # String length is 0 It is true
-n # String length is not 0 It is true
EOF
str1="runoob1"
str2="runoob2"
if test $str1 = $str2
then
echo str1=str2
else
echo str1 It's not equal to str2
fi
# String length
if test -z $str2
then
echo str2 is empty
else
echo str2 is not empty
fi
# ( 3、 ... and ) File test
:<<EOF
-e file name True if the file exists
-r file name True if the file exists and is readable
-w file name True if the file exists and is writable
-x file name True if the file exists and is executable
-s file name True if the file exists and has at least one character
-d file name True if the file exists and is a directory
-f file name True if the file exists and is a normal file
-c file name True if the file exists and is a special character file
-b file name True if the file exists and is a block special file
EOF
if test -e ./myfile
then
echo myfile There is
else
echo myfile non-existent
fi
# (3) If then If you start a new line then There is no need to add ; Otherwise, it needs to be in then Before to add ;
if [ -d "/data/" ];then
echo "data Folder exists "
else
echo "data Folder does not exist "
fi
# (4)"/data/" Double quotation marks can be removed .
# ( Four ) And or not -a -o !
# Shell It also provides ( -a )、 or ( -o )、 Not ( ! ) Three logical operators are used to connect test conditions
# Its priority is : ! The highest , -a second , -o The minimum
if [ -e ./notFile -o -e ./myfiel ]; then
echo " At least one file exists "
else
echo " It doesn't exist "
fi
边栏推荐
- Day07-ORM表关系及操作
- Day10 front back continuous adjustment
- elemtnui 表格如何修改某行文字颜色(elemtnui table 修改某行文字颜色)
- 使用bat自动执行cmd命令(多个命令或单个命令)
- @Configurationproperties annotation usage
- Day13 mixed view base class
- Eye of depth III - (7)] mathematics: application of SVD decomposition
- Record a bug that failed to pass the authentication of calling feign interface in the scheduled task
- Vue project deployment, cleaning cache
- Day16 sorting, current limiting
猜你喜欢

Oracle automatic storage management 18C step-by-step installation -2

JSX 语法

object-fit:cover; It doesn't work in the applet. How to deal with the deformation of the applet image
![Eye of depth III - (7)] mathematics: application of SVD decomposition](/img/18/f69d012ebadf2c7aedfbea40ae1cf5.png)
Eye of depth III - (7)] mathematics: application of SVD decomposition
![Eye of depth III - (3)] mathematics: matrix eigenvalue and eigenvector 1](/img/81/7ad44da70eaf1d92b126c567766577.png)
Eye of depth III - (3)] mathematics: matrix eigenvalue and eigenvector 1

Three activation functions (relu, sigmoid, tanh) and multilayer perceptron

js字符串转对象 js对象转字符串 js字符串与对象互转

页面布局——三栏布局解决方式

【ElenmentUI el-date-picker日期选择器,结束时间不得早于开始时间,且只能选择距开始时间指定天数的日期】

小程序嵌入网页向小程序跳转并传参,微信小程序中实现公众号授权获取openId
随机推荐
uni-app微信公众号(4)——地址管理页面
Day14 view set and route
学习STM32F103时涉及的C语言知识汇总(仅链接)
Maker-鸿蒙应用开发培训笔记03
Vue project deployment, cleaning cache
markdown编辑器语法——文字颜色、大小、字体与背景色的设置(转载)
ModelArts-人声检测and文本分类
promise
智能指针(shared_ptr、unique_ptr、weak_ptr)
object-fit:cover;在小程序中不起作用,小程序图片变形了如何处理
深度之眼三——(3)】 數學:矩陣特征值與特征向量1
P6-day01-通用试图(P4复习)
(九)Shell 输入输出重定向
Pytoch simply uses the Minist dataset
Day15 paging, filtering
Day06 ORM field and operation
Day12 Association serialization processing
XSS simple summary
js获取一个文件名的后缀格式
[elementui El date picker date selector, the end time must not be earlier than the start time, and only the date of the specified number of days from the start time can be selected]