Shell 流程控制 和Java.PHP等语言不一样,sh的流程控制不可为空,如(以下为PHP流程控制写法): <?php if (isset($_GET["q"])) { search(q); } else { // 不做任何事情 } 在sh/bash里可不能这么写,如果else分支没有语句执行,就不要写这个else. if else if if 语句语法格式: if condition then command1 command2 ... commandN fi 写成一行(适…
和Java.PHP等语言不一样,sh的流程控制不可为空,如(以下为PHP流程控制写法): <?php if (isset($_GET["q"])) { search(q); } else { // 不做任何事情 } 在sh/bash里可不能这么写,如果else分支没有语句执行,就不要写这个else. 1.if else if if 语句语法格式: if condition then command1 command2 ... commandN fi 写成一行(适用于终端命令提示符…
今日目录: 一.流程控制 1. if 2. while 3. for 4. 后期补充内容 一.流程控制--if 1.if判断: # if判断 age = 21 weight = 50 if age > 18 and age < 25 and weight >40 and weight < 60: print("表白...") 2.if+else: # 语法二:if - else age = 21 weight = 50 if age > 18 and ag…