当前位置:网站首页>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
边栏推荐
猜你喜欢

File viewing commands and user management commands
![[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

非参数化相机畸变模型简介

gcc ,g++,gdb的安装

cv_bridge 与opencv 版本不匹配的解决

卷积神经网络实现CIFAR100数据集分类
[ThreadX] h743 + ThreadX + Filex migration record

jenkspy包安装

【UDS统一诊断服务】二、网络层协议(2)— 数据传输规则(单帧与多帧)

clion安装教程
随机推荐
【UDS统一诊断服务】五、诊断应用示例:Flash Bootloader
WMI技术介绍和应用
C语言数组处理批量数据
搭建jpress个人博客
Completely clean up MySQL win
爬取小米有品app商品数据
圆整 round 的一点点小细节
cv_bridge 与opencv 版本不匹配的解决
Introduction to nonparametric camera distortion model
Eigen 库常用基本用法 备忘
【UDS统一诊断服务】四、诊断典型服务(3)— 读故障信息功能单元(存储数据传输功能单元)
Friend function, friend class, class template
vs中能编译通过,但是会有红色下划线提示未定义标示符问题
[UDS unified diagnostic service] IV. typical diagnostic service (2) - data transmission function unit
Robocode教程5——Enemy类
[ThreadX] h743zi + lan8720 + ThreadX + netx duo transplantation
Programmers can also write novels
C语言进阶要点笔记3
爬取彩票数据
Protection of shared data