linux的shell的until循环举例说明
执行脚本: sh login.sh user,其中user为第一个参数
如下所示,如果用户‘user’登录,'who | grep "$1"'为true,until循环结束,程序继续执行,输出 “***** user has just logged in *****”信息。
如果用户‘user’没有登录,屏幕每隔60秒打印一次“ok”。
$1表示程序的第一个参数
# login.sh
1 #!/bin/bash until who | grep "$1" > /dev/null
do
sleep 60
echo 'ok'
done # Now ring the bell and announce the unexpected user. echo -e '\a'
echo "***** $1 has just logged in *****" exit
linux的shell的until循环举例说明的更多相关文章
- linux shell条件与循环举例
1. if/else 语句 语法: if condition; then commands;elif condition; then commands;else commands;fi 示例:需求:脚 ...
- Linux - 简明Shell编程06 - 循环语句(Loop)
脚本地址 https://github.com/anliven/L-Shell/tree/master/Shell-Basics 示例脚本及注释 #!/bin/bash # for循环 for fil ...
- Linux下Shell的for循环语句
第一类:数字性循环-----------------------------for1-1.sh #!/bin/bash ;i<=;i++)); do + ); done ------------ ...
- Linux centosVMware shell编程 for循环、while循环、break跳出循环、continue结束本次循环、exit退出整个脚本
一.for循环 语法:for 变量名 in 条件; do …; done 案例1 #!/bin/bash sum=0 for i in `seq 1 100` do sum=$[$sum+$i] ec ...
- Linux shell编程 4 ---- shell中的循环
1 for循环 1 for语句的结构 for variable in values; do statement done 2 for循环通常是用来处理一组值,这组值可以是任意的字符串的集合 3 for ...
- Linux和Shell教程
文档资料参考: 参考:http://www.runoob.com/linux/linux-tutorial.html 软件下载参考: centos 下载地址:https://www.centos.or ...
- linux中用shell获取昨天、明天或多天前的日期
linux中用shell获取昨天.明天或多天前的日期 时间 -- :: BlogJava-专家区 原文 http://www.blogjava.net/xzclog/archive/2015/12/0 ...
- linux中用shell获取时间,日期
linux中用shell获取昨天.明天或多天前的日期:在Linux中对man date -d 参数说的比较模糊,以下举例进一步说明:# -d, --date=STRING display time d ...
- Linux Bash Shell 快速入门
BASH 的基本语法 最简单的例子 —— Hello World! 关于输入.输出和错误输出 BASH 中对变量的规定(与 C 语言的异同) BASH 中的基本流程控制语法 函数的使用 2.1 ...
随机推荐
- C++_pthread read-write lock_读写锁_visual studio 2015下配置
pthread下载地址:https://sourceware.org/pthreads-win32/ 1. 项目->属性->VC++目录 包含目录里添加:pthread所在路径\pthre ...
- MFC实现类似spy++dm取句柄功能
处理WM_MOUSEMOVE消息 HANDLE_MSG( hwnd , WM_MOUSEMOVE, OnMouseMove ) 在OnMouseMove中, 设置SetCaputre() 移动鼠标到目 ...
- RN传参的问题
RN父组件通过props属性给子组件传参,假设参数 target={target} 子组件在render函数里 let { target } = this.props; 如果子组件有个 FlatLis ...
- 第三讲:post-processsing with vcs+ files
1,dump wave by system function $vcdpluson(level_number,module_instance,....|net_or_reg) $vcdplusoff ...
- python基础 : 1.计算机基础 2.注释 3.变量 4.标识符 5.输出 6.格式化输出 7.输入 8.算数运算符 9.字符串操作
- Python的串口
要使用python中的串口,可以下载pywin32-224-cp36-cp36m-win_amd64.whl去安装或者pip install去安装. 调试下来,有一点很不爽,读取read()数据的ti ...
- [图文教程] 使用Git 提交项目到码云
目录 1. 环境准备 2. 开发工具配置Git和SSH 3. 配置SSH到码云 4. 创建一个项目 5. Clone项目到本地 6. Push项目到码云 1. 环境准备 1.1 本机配置Git Hom ...
- shell实现ftp命令示例
一.shell脚本示例: [plain] view plaincopy cd /PATH_YOU_WANT_TO_UPLOAD(DOWNLOAD) ftp -niv <<- EOF ope ...
- javascript、jquery 、C#、sqlserveer、mysql、oracle中字符串截取的区别和用法
下标从0开始 ,并且包括起始位 javascript 中字符串截取 : substring(Number start,Number end) var substr = "liuguangfa ...
- 【优先级队列】Southwestern Europe Regional Contest Canvas Painting
https://vjudge.net/contest/174235#problem/D [题意] 给定n个已知size的帆布,要给这n块帆布涂上不同的颜色,规则是这样的: 每次选择一种颜色C 对于颜色 ...