恶搞普通用户终端shell脚本

前端之家收集整理的这篇文章主要介绍了恶搞普通用户终端shell脚本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
functionjoke(){
NUM=0
people_list=$(w|sed'1,2d'|awk'{print$1}')
foruserin$people_list
do
	if[$user!="root"]
	then	
		#echo$user
		info=$(w|sed'1,2d'|grep"^$user")
		pts=$(echo$info|awk'{print$2}')
		while[$NUM-lt$1]
		do
			echo-e"\033[31mhello$NUMworld\033[0m">/dev/$pts
			sleep1
			letNUM++
		done&
		echo"pidis$!$$"
		wait

	fi
done
}
if[$#==1]
then
	joke$1
	echo
else
	echo"user$0num"
fi


functiontwo(){
PTS_LIST=$(w|sed'1,2d'|awk'{if($1!="root")print$2}')#第二种方法用awk来取得pts列表
NUM=0
forptsin$PTS_LIST
do
	while[$NUM-lt$1]
	do
		echo"helloworld">/dev/$pts
		echo"/dev/$pts"
		letNUM++
	done&
	wait
done


}@H_502_1@ 原文链接:https://www.f2er.com/bash/388836.html

猜你在找的Bash相关文章