shell while true break 循环语句 详解
<p>shell while true break 循环语句 是非常重要的, 这篇文章,就带大家认识一下:shell while true循环</p> <h3>1)shell while true循环</h3> <pre><code>[root@baimeidashu ~]#cat while.sh #!...
51工具盒子
<p>shell while true break 循环语句 是非常重要的, 这篇文章,就带大家认识一下:shell while true循环</p> <h3>1)shell while true循环</h3> <pre><code>[root@baimeidashu ~]#cat while.sh #!...
这篇文章主要介绍 一下 shell if else语句嵌套的例子 很多初学者,或者刚接触 linux shell 编程的朋友 对shell if else elif 的语法 还不是很熟悉。 首先 shell中if else语法 有 2种 ,主要区别是 then 的位置。 ### (1) 第1种 if [ 表达式 成立 ]; then 执行的具体命...
案例: -d 如果目录不存在则创建 [ -d /etc ] && mkdir /opt/`hostname`_`date +%F` && tar zcvf /opt/`hostname`_`date +%F`/etc.tar.gz /etc #!/bin/bash [ -f /server/scripts/day...
shell 编程中 文件判断 ### 1文件判断 语法结构: test 判断符 文件或者目录 \[ 判断符 文件或者目录 \] 判断符: -f 文件存在则为真 -d 目录存在则为真 -e 文件存在则为真(任意类型的文件) -r 文件可读为真 -w 文件可写为真 -x 文件可执行为真 test -f /etc/passwd &...
shell编程中 整数比较 (1) test A -gt B test 10 -gt 4 && echo 正确 || echo 不正确 (2) \[ A -gt b\] (注意空格) [ 10 -gt 5 ]&& echo 正确 || echo 错误 </h3> <p>取出name中的 me</p> <pre><code>[root@baimeidashu ~]#name='baimei' [root@baimeidashu ~]#echo ${name...
<p>如果是毫秒怎么办?</p> <p>shell 里边 有2个命令,可以延迟, 针对毫秒的要注意</p> <h3>(1)sleep 针对 秒级别</h3> <pre><code>sleep 1 # 表示延迟1秒 sleep 1s # 表示延迟1秒 sleep 1m #...
shell 变量的3中传参方式 ### (1)直接传参 sh test.sh a b ### (2) 赋值传参 #!/bin/bash name=$1 age=$2 ### (3)read 读入 #!/bin/bash read -p "请您输入您的姓名: " name read -...
shell 中重要的 位置变量 $0,$#, $? $$ $_ $\* $@ ### (1) $0 表示脚本的名称  ![]...
shell变量值的定义 ### (1) 数字的定义 连续的数字 age=234 不连续的用 单引号或者 双引号 age='23 4' ### (2)字符串的定义 dir=/etc/sysconfig/network-scripts/ifcfg-eth0 dir=''/etc/sysconfig/ne...