
Shell
plyukulong2008
这个作者很懒,什么都没留下…
展开
-
Shell编程学习-查看用户登录时间
该例子为《Unix Shell编程》的课后题。实现简单的功能:显示一个用户登录到系统的小时数和分钟数(假定不超过24小时)[ $# -ne 1 ]&&echo "usage:con user"&&exit 1h=$(who|grep "^$1 "|cut -c30,31|sed -n "1p")m=$(who|grep "^$1 "|cut -c33,34|sed -n "1p")原创 2012-03-29 16:48:30 · 693 阅读 · 0 评论 -
getopts的使用
getopts用来在shell中处理参数。用法如下:#!/bin/bashfrom=""to=""while getopts f:t: optdo case "$opt" in f)from="$OPTARG";; t)to="$OPTARG";; *)echo "Usage:cnt -f from -t to" exit原创 2012-04-05 10:05:59 · 856 阅读 · 0 评论