shell条件与循环
一.if语句
if [expression]
then
elif[expression]
then
else
fi
注 : expression前后要有空格;判断相等用 = 而不是 == ;
then可以另起一行,也可以与if同行,同行时要加';';
二.case模式
case值 in
模式1)
command1
command2
command3
;;
模式2)
command1
command2
command3
;;
*)
command1
command2
command3
;;
esac
例 :
case $value in
value1)
command
;;
value2)
command
;;
esac
三.for循环
for 变量 in 列表
do
command1
command2
...
commandN
done
四.while循环
while [ command ]
do
Statement(s) to be executed if command is true
done
五.util循环
until command
do
Statement(s) to be executed until command is true
done
shell条件与循环的更多相关文章
- linux shell条件与循环举例
1. if/else 语句 语法: if condition; then commands;elif condition; then commands;else commands;fi 示例:需求:脚 ...
- linux shell 流程控制(条件if,循环【for,while】,选择【case】语句实例 --转载
http://www.cnblogs.com/chengmo/archive/2010/10/14/1851434.html nux shell有一套自己的流程控制语句,其中包括条件语句(if),循环 ...
- shell条件控制和循环结构
一.简介 Shell编程中循环命令用于特定条件下决定某些语句重复执行的控制方式,有三种常用的循环语句:for.while和until.while循环和for循环属于“当型循环”,而until属于“直到 ...
- [转]linux shell 流程控制(条件if,循环【for,while】,选择【case】语句实例
原文链接:http://www.cnblogs.com/chengmo/archive/2010/10/14/1851434.html linux shell有一套自己的流程控制语句,其中包括条件语句 ...
- Python基础(6)--条件、循环
本文的主要内容是 Python 的条件和循环语句以及与它们相关的部分. 我们会深入探讨if, while, for以及与他们相搭配的else,elif,break,continue和pass语句. 本 ...
- shell脚本学习-循环
跟着RUNOOB网站的教程学习的笔记 for循环 与其他编程语言类似,shell支持for循环. for循环一般格式为: for var in item1 item2 ... itemN do com ...
- 04 shell编程之循环语句
Shell编程之循环语句 学习目标: 掌握for循环语句编程 掌握while循环语句编程 目录结构: For循环语句 l 读取不同的变量值,以逐个执行同一组命令 l For语句结构 for 变量名 ...
- Shell中的循环语句实例
1.for循环语句实例1.1 最基本的for循环 #!/bin/bash for x in one two three four do echo number $x done 注:" ...
- shell分支与循环结构
1. 条件选择 1.1 条件判断分支介绍 格式 if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMM ...
随机推荐
- django 1.5+ 权限设计浅析
权限关系图 依赖app: django.contrib.auth django.contrib.contenttype admin后台的权限控制解析 (path/to/django.contrib.a ...
- php友好格式化时间
php格式化时间显示 function toTime($time) {//$time必须为时间戳 $rtime = date("Y-m-d H:i",$time); $htime ...
- VirtualBox共享文件夹等高级特性
转自: http://blog.csdn.net/longerzone/article/details/32119457 http://www.oschina.net/translate/10-vir ...
- .NET Reflector 7.6.1.824 Edition .NET程序反编译神器(附插件安装教程2012-10-13更新) 完全破解+使用教程
原文来自VAllen cnblogs 一.使用教程1.解压后,双击Reflector.exe,如果有选择默认版本的.Net Framework,根据需要选择即可.你选择的版本不同则出现的默认程序集也不 ...
- HTML5 manifest离线缓存
一.基本概念 离线缓存是HTML5新引入的技术,能够让你的Web应用程序指定哪些文件可以缓存在本地,使得你的网络断开时依然可以通过本地的缓存来进行访问浏览. 二.使用方法 1. MIME type 声 ...
- #ifdef 的技巧用法
-- int _tmain(int argc, _TCHAR* argv[]) { #ifdef DEBUG cout<<"DEBUG has been defined" ...
- 【转】javax.net.ssl.SSLHandshakeException(Cas导入证书)
本文转自:http://my.oschina.net/laiwanshan/blog/159057 一.报错: javax.net.ssl.SSLHandshakeException 二.原因分析:C ...
- poj1185
状态压缩dp #include <cstdio> #include <cstring> #include <cstdlib> #include <iostre ...
- iOS 中的Push Notifications简单实现(APNS)
Android中的通知只有一种,就是Local Notifications,而iOS中除了Local Notifications外,还有一种Push Notifications.ios的这2种noti ...
- MYSQL 删除字段值为NULL的语法
2014年9月1日 15:11:05 delete form your_table where your_field is null and your_field1 = '123' ...