【shell】 for循环
#!/bin/bash
for i in 1,3,4,6 ##有几个数就循环几次
do
echo $i
done for m in $( cat /root/num.log) ## /root/num.log有几行就循环几次
do
echo -e "$m \n" ##echo -e 才能识别“\n”
done
read -p "please input default name: " name
read -p "please input num of users: " num if [ ! -z "$name" -a ! -z "$num" ] ###需要注意的是!和 -z中间必须有空格
then
y=$(echo $num|sed 's/[0-9]//g') ##判断是否为纯整数
if [ -z $y ]
then
for ((i=1;i<=$num;i=i+1))
do
echo "add user $name_$i"
done
fi
fi
【shell】 for循环的更多相关文章
- Linux Shell系列教程之(十二)Shell until循环
本文是Linux Shell系列教程的第(十二)篇,更多Linux Shell教程请看:Linux Shell系列教程 在上两篇文章Linux Shell系列教程之(十)Shell for循环和Lin ...
- shell for循环+case的脚本(监控程序状态)
分享一个shell for循环+case的脚本(监控程序状态) 分享一个for循环+case的脚本(监控程序状态并执行相关操作) ,供大家学习参考. 复制代码代码如下: #/bin/bash set ...
- shell 各种循环判断
shell支持的循环有 Shell if else Shell case esac Shell for循环 Shell while循环 Shell until循环
- shell脚本--循环结构
shell的循环结构有while和for两种 for循环 #!/bin/bash #文件名:test.sh i=4 for i in 2 4 6 8 10 do echo $i done echo $ ...
- Linux Shell系列教程之(十一)Shell while循环
本文是Linux Shell系列教程的第(十一)篇,更多Linux Shell教程请看:Linux Shell系列教程 在上一篇Linux Shell系列教程之(十)Shell for循环中,我们已经 ...
- Linux Shell系列教程之(十)Shell for循环
本文是Linux Shell系列教程的第(十)篇,更多Linux Shell教程请看:Linux Shell系列教程 基本任何语言都有自己的循环语句,Shell当然也不例外,今天就为大家介绍下Shel ...
- shell脚本-循环选择语句
shell脚本-循环选择语句 过程式编程语言: 顺序执行 选择执行 循环执行 注:条件中的变量,可以在执行语句中使用,不用在加上"$". if语句 根据命令的退出状态来执行命令 单 ...
- Linux shell for循环结构
Linux Shell for循环结构 循环结构 1:循环开始条件 2:循环操作 3:循环终止的条件 shell语言 for,while ...
- Shell 编程 循环语句
本篇主要写一些shell脚本循环语句的使用. for 循环 指定次数 #!/bin/bash for ((i=1;i<=10;i++)) do echo $i done [root@localh ...
- Linux 之Shell for循环
@代表所有参数所以如果后面跟上echo $v你会发现他会一次显示user userdebug eng $poo -le ${#prodlist[@]} 这句话是说 $poo小于等于prodlist中的 ...
随机推荐
- Web 仪表盘
/*********************************************************************** * Web 仪表盘 * 说明: * 之前很久,都想知道 ...
- HDU 1002 A + B Problem II(AC代码)
#include <stdio.h> #include <string.h> #define MAX 1009 int main() { },b[MAX]={}; ,z=,r= ...
- html 遇到margin居中的问题
今天在写div时发现不居中, div{ margin:0 auto; } 那么给div一个固定的宽度,就会居中了 div{ margin:0 auto; width:500px; }
- python 文件操作,seek, tell, name...
可以设置文件当前位置偏移 fileObject.seek(offset [, whence]) offset 文件的读/写指针位置 whence 可选,默认0,相对于文件开始的位置. 1, 相对于目前 ...
- LINQ 按多个字段排序
多字段排序 添加到 LINQ 查询结果中的Take()扩展方法用于提取前 个结果: private static void Ordering() { var racers = (from r in F ...
- My97DatePickerBeta 时间选择控件用法
用法说明:只需要调用一个js<script language="javascript" type="text/javascript" src=" ...
- Spring+SpringMVC+Mybatis+ehcache
http://www.tuicool.com/articles/myeANv http://www.mamicode.com/info-detail-1151624.html
- MATLAB格式化输出控制
format 默认格式 format short 5字长定点数 format long 15字长定点数 format short e 5字长浮点数 format long e 15字长浮点数 form ...
- Android SDK Manager Google Apis 下载
本意是想利用google的gcm来实装android推送功能的,很遗憾, google貌似已经停止提供啥服务给国内了,或者说国内想继续使用google 服务暂时变得几乎不可能了.找了个代理来进行goo ...
- php遇见的错误(一)
1.linux 执行脚本时报的错 Call to a member function on a non-object in 是没有实例化对象 解决方法 new类2.在给一个表增加一个新字段或者改 ...