首页 > 系统服务 > 详细

恶搞普通用户终端shell脚本

时间:2018-02-01 18:23:27      阅读:302      评论:0      收藏:0      [点我收藏+]
cat a.sh function joke(){ NUM=0 people_list=$(w | sed '1,2d' | awk '{print $1}') for user in $people_list do if [ $user != "root" ] then #echo $user info=$(w | sed '1,2d' | grep "^$user") pts=$(echo $info | awk '{print $2}') while : do echo -e "\033[31mhello $NUM world\033[0m" >/dev/$pts sleep 1 let NUM++ if [ $NUM -gt $1 ] then break fi done & echo "pid is $!" fi done } joke $1


sh a.sh 10 

效果如下:

[test@centos-6_5 ~]$ hello 0 world

hello 1 world

hello 2 world

hello 3 world

hello 4 world

hello 0 world

hello 1 world

hello 2 world

hello 3 world

hello 4 world

hello 5 world

hello 6 world

hello 7 world

hello 8 world

hello 9 world

hello 10 world



可以加为定时任务

恶搞普通用户终端shell脚本

原文:http://blog.51cto.com/19941018/2067842

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!