当前位置:网站首页>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 |
边栏推荐
- leetcode 903. DI 序列的有效排列
- OPC of Beifu twincat3_ UA communication test case
- Yunlong fire version aircraft battle (full version)
- Cvpr2022 𞓜 future transformer with long-term action expectation
- Beifu PLC controls servo through CANopen communication
- Qt中的UI文件介绍
- Lm07 - detailed discussion on cross section strategy of futures
- C#二叉树结构定义、添加节点值
- STK_ Gltf model
- 树状数组应用(AcWing 242,243,244)
猜你喜欢

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

Don't build the wheel again. It is recommended to use Google guava open source tool class library. It is really powerful!

Server monitoring netdata panel configuring mail service

AES-128-CBC-Pkcs7Padding加密PHP实例

Precautions for Beifu controller connecting Panasonic EtherCAT servo

倍福TwinCAT配置、调试第三方伺服详细讲解--以汇川IS620N为例子

Cvpr2022 𞓜 future transformer with long-term action expectation

Simple introduction to matlab

C # indexe l'arbre binaire en traversant l'ordre moyen

Cvpr2022 | a convnet for the 2020s & how to design neural network Summary
随机推荐
qt json
C # indexe l'arbre binaire en traversant l'ordre moyen
Golang image/png processing image rotation writing
qt 自定义控件 :取值范围
23、 1-bit data storage (delay line / core /dram/sram/ tape / disk / optical disc /flash SSD)
Viewing splitchunks code segmentation from MPX resource construction optimization
Install the terrain ovirt plug-in to provide automated management for ovirt
B+树|MYSQL索引使用原则
中职网络安全技能竞赛之应用服务漏洞扫描与利用(SSH私钥泄露)
asp.net 项目使用aspnet_compiler.exe发布
The former security director of Uber faced fraud allegations and concealed the data leakage event
Code tidiness learning notes
服务器监控netdata面板配置邮件服务
Install the typescript environment and enable vscode to automatically monitor the compiled TS file as a JS file
C语言的指针详解
C语言模拟实现所有字符函数
Simple introduction to matlab
[environment configuration]pwc-net
asp. Net project using aspnet_ compiler. Exe Publishing
CVPR 2022 | unknown target detection module study: learning unknown targets in video