当前位置:网站首页>Shell judges whether the command is executed successfully
Shell judges whether the command is executed successfully
2022-06-29 13:16:00 【Know the old code】
shell Judge whether the command is executed successfully
Determine whether the last command was successful
#!/usr/bin/env bash
# This script is used to demonstrate : Determine whether the last command was successful
# Whether the last command is not equal to 0
if [ $? -ne 0 ]; then
echo "failed"
else
echo "succeed"
fi
# Whether the status of the previous command is equal to 0
if [ $? -eq 0 ]; then
echo "succeed"
else
echo "failed"
fi
# Suggested code style : If the command is not executed , Print execution failed
if ! make mytarget; then
echo "Build failed"
fi
shell Comparison operator
Reference resources : https://blog.mimvp.com/article/7415.html
| Operator | explain |
|---|---|
| -eq | be equal to |
| -ne | It's not equal to |
| -gt | Greater than |
| -lt | Less than |
| ge | Greater than or equal to |
| le | Less than or equal to |
边栏推荐
- mysql调优
- C#实现顺序表定义、插入、删除、查找操作
- 倍福控制器连接松下EtherCAT伺服注意事项
- Cnpm reports an error 'cnpm' is not an internal or external command, nor is it a runnable program or batch file
- 安装typescript环境并开启VSCode自动监视编译ts文件为js文件
- CVPR2022 | A ConvNet for the 2020s & 如何设计神经网络总结
- C#实现二叉树的层次遍历
- Netdata mail alarm configuration
- Tutorial on building pytoch model from zero (IV) compiling training process -- Parameter Analysis
- Matlab to find the limit
猜你喜欢

从零搭建Pytorch模型教程(四)编写训练过程--参数解析

CVPR2022 | 可精简域适应

CVPR 2022 | 未知目标检测模块STUD:学习视频中的未知目标

中职网络安全技能竞赛之应用服务漏洞扫描与利用(SSH私钥泄露)

Schiederwerk Power Supply repair smps12 / 50 pfc3800 Analysis

Interesting talk on network protocol (II) transport layer

Aes-128-cbc-pkcs7padding encrypted PHP instance

C语言内存函数

CVPR2022 | 通过目标感知Transformer进行知识蒸馏

C#实现图的邻接矩阵和邻接表结构
随机推荐
超 Nice 的表格响应式布局小技巧
倍福控制器连接松下EtherCAT伺服注意事项
cnpm报错‘cnpm‘不是内部或外部命令,也不是可运行的程序或批处理文件
ZALSM_EXCEL_TO_INTERNAL_TABLE 导入数据大问题解决
leetcode 903. DI 序列的有效排列
安装terraform-ovirt插件为ovirt提供自动化管理
leetcode 903. Effective arrangement of Di sequences
Yunlong fire version aircraft battle (full version)
hutool工具类的学习(持续更新)
从零搭建Pytorch模型教程(五)编写训练过程--一些基本的配置
C#实现二叉树非递归中序遍历程序
bind原理及模拟实现
趣谈网络协议(二)传输层
STK_GLTF模型
Yolo series combs (IX) first taste of newly baked yolov6
Schiederwerk Power Supply repair smps12 / 50 pfc3800 Analysis
[environment configuration]pwc-net
Problem solving: modulenotfounderror: no module named 'pip‘
Schiederwerk power supply maintenance smps12/50 pfc3800 analysis
Equidistant segmentation of surface rivers in ArcGIS [gradient coloring, pollutant diffusion]