shell基础之exit,break,continue
exit代码:
1 #!/bin/bash
2 echo "Is it morning? Please answer yes or no."
3 read YES_OR_NO
4 case "$YES_OR_NO" in
5 yes|y|Yes|YES)
6 echo "Good Morning!";;
7 [nN]*)
8 echo "Good Afternoon!";;
9 *)
10 echo "Sorry,$YES_OR_NO not recongnized.Enter yes or no."
11 esac
12 exit 0
exit(0):正常运行程序并退出程序;
exit(1):非正常运行导致退出程序;
exit 0 可以告知你的程序的使用者:你的程序是正常结束的。如果 exit 非 0 值,那么你的程序的使用者通常会认为你的程序产生了一个错误。
在 shell 中调用完你的程序之后,用 echo $? 命令就可以看到你的程序的 exit 值。在 shell 脚本中,通常会根据上一个命令的 $? 值来进行一些流程控制。
continue:跳过本次循环体中余下尚未执行的语句(退出当前循环),立即进入下一次的循环;也就是仅结束本次循环
break:退出本层循环
shell基础之exit,break,continue的更多相关文章
- [转帖]Shell脚本中的break continue exit return
Shell脚本中的break continue exit return 转自:http://www.cnblogs.com/guosj/p/4571239.html break结束并退出循环 cont ...
- centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课
centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 ...
- Shell脚本中的break continue exit return
转自:http://www.cnblogs.com/guosj/p/4571239.html break结束并退出循环 continue在循环中不执行continue下面的代码,转而进入下一轮循环 e ...
- (转)Shell脚本之break,continue,和exit区别
Linux脚本中的break continue exit return break结束并退出循环 continue在循环中不执行continue下面的代码,转而进入下一轮循环 exit退出脚本,常带一 ...
- break , continue , exit
break , continue , exit 例一:#!/bin/bash . /etc/init.d/functions `;do ];then #continue #没有数字3 break #e ...
- Java基础(2):Java中的四个跳转语句总结goto,break,continue,return
跳转控制语句 Java中的goto是保留字,目前不能使用.虽然没有goto语句可以增强程序的安全性,但是也带来很多不便,比如说,我想在某个循环知道到某一步的时候就结束,现在就做不了这件事情.为了弥补这 ...
- C++中break/Continue,exit/return的理解
刚才遇到了一个问题,大概是这样的. func1执行完成,进入func1Complete,其中switch处理func1返回的数据,如果返回数据是clear则重新执行func1. 测试的时候发现func ...
- break continue exit return 的区别
[root@localhost day1]# cat ss.sh #!/bin/bash for ((i=0;i<5;i++)) do if [ $i -eq 3 ] then break #c ...
- Python break/continue - Python零基础入门教程
目录 一.break 二.continue 三.重点总结 四.猜你喜欢 零基础 Python 学习路线推荐 : Python 学习目录 >> Python 基础入门 在 Python wh ...
随机推荐
- @Transactional+@Autowired出现的lateinit property xx has not been initialized错误
1 问题描述 用Kotlin编写Spring Boot,在业务层中使用@Transactional+@Autowired时出现如下错误: lateinit property dao has not b ...
- Pycharm Fiddler Requests https in _create raise ValueError("check_hostname requires server_hostname
打开Fiddler, 开启抓取https, 在PyCharm中使用requests 发送https请求, 遇到 in _create raise ValueError("check_ho ...
- Linux入门之基本的概念、安装和操作
目录 Linux基本概念 Linux的安装 虚拟机安装CentOS7 CentOS设置网络 Linux基本操作命令 文件目录操作命令 进程操作命令 文本操作命令 Linux权限操作 用户和组操作命令 ...
- WinForm只运行运行一个实例(单开)
using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.F ...
- vagrant构建centos虚拟环境
vagrant搭建centos 什么是vagrant 如何使用 1.构建本地的目录 2.官方下载对应的镜像文件,官方下载地址 3.导入刚刚下载的镜像(box文件) 4.初始化 5.修改Vagrantf ...
- 微信小程序 icon组件详细介绍
这些是提供的所支持的图标样式,根据需求在此基础上去修改大小和颜色. 主要属性: 使用方式: wxml <!--成功图标--> <icon type="success&quo ...
- Spring Security 上
Spring Security 上 Security-dome 1.创建项目 创建一个Spring Boot项目,不用加入什么依赖 2.导入依赖 <dependencies> <!- ...
- ubuntu 1804 配置阿里源
以防出错,先备份sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak编辑元列表文件sudo vim /etc/apt/sources.list ...
- Linux文件共享服务之NFS
NFS(Network File System) 网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间通过TCP/IP网络共享资源.在NFS的应用中,本地NFS的客户端应用可 ...
- Python中python-nmap模块的使用
目录 python-nmap的安装 python-nmap模块的使用 portScanner()类 环境: python 2.7.13 Windows和Linux默认都是不安装python-nmap ...