当前位置:网站首页>Shell脚本 &&和||的使用
Shell脚本 &&和||的使用
2022-04-23 05:50:00 【tilblackout】

- 如果前一个指令执行正确,在Linux中会回传一个$?=0的值
例1:判断文件是否存在,存在则创建另一个文件
ls /tmp/abc && touch /tmp/abc/hehe
例2:判断文件是否存在,不存在创建,存在则不做任何事
ls /tmp/abc || touch /tmp/abc
例3:判断文件是否存在,存在显示"exist",不存在显示"not exist"
#有多个指令时按顺序执行,后一个根据前一个的$?执行
ls /tmp/vbirding && echo "exist" || echo "not exist"
#不显示ls输出的结果
ls 1.txt >/dev/null 2>&1 && echo "exist" || echo "not exist"
版权声明
本文为[tilblackout]所创,转载请带上原文链接,感谢
https://blog.csdn.net/tilblackout/article/details/123411920
边栏推荐
- Camera calibration: key point method vs direct method
- 【UDS统一诊断服务】一、诊断概述(1)— 诊断概述
- 在MFC中使用printf
- [UDS unified diagnostic service] II. Network layer protocol (2) - data transmission rules (single frame and multi frame)
- [UDS unified diagnostic service] II. Network layer protocol (1) - overview and functions of network layer
- 修改注册表的值
- Robocode教程7——雷达锁定
- 大学概率论与数理统计知识点详细整理
- 猜數字遊戲
- sqlite3加密版
猜你喜欢

Robocode教程8——AdvancedRobot

类的继承与派生

for()循环参数调用顺序
逻辑回归原理及代码实现

Initialization of classes and objects (constructors and destructors)

C语言循环结构程序

基于SSD的物体检测案例实现

【UDS统一诊断服务】四、诊断典型服务(3)— 读故障信息功能单元(存储数据传输功能单元)

C语言实用小技巧合集(持续更新)
![[UDS unified diagnosis service] IV. typical diagnosis service (1) - diagnosis and communication management function unit](/img/4f/7ca6505b545fb825b0dba36f474da7.png)
[UDS unified diagnosis service] IV. typical diagnosis service (1) - diagnosis and communication management function unit
随机推荐
For() loop parameter call order
Arcpy为矢量数据添加字段与循环赋值
Eigen 库常用基本用法 备忘
C语言进阶要点笔记3
C语言输入和输出(printf和scanf函数、putchar和getchar函数)
Qt 给应用程序加图标
安装pyshp库
ArcGIS表转EXCEL超出上限转换失败
在MFC中使用printf
[opencv] use filestorage to read and write eigenvectors
圆整 round 的一点点小细节
如何读文献
C语言进阶要点笔记2
cv_bridge 与opencv 版本不匹配的解决
[UDS unified diagnosis service] i. diagnosis overview (2) - main diagnosis protocols (K-line and can)
cuda工程更换环境(电脑)后遇到的一系列编译问题
C语言数组处理批量数据
Detailed arrangement of knowledge points of University probability theory and mathematical statistics
_findnext 报错
OpenCV使用 GenericIndex 进行 KNN 搜索