数字代表命令的脚本和升级版

数字代表命令的脚本

#! /bin/bash
while :
   do
	read -p "please name a number(1-4):" n
	if echo $n | grep -v '^[0-9]$' >> /dec/null
	   then
		echo "format wrong"	
		continue
	fi
	if [ $n -gt 4 ] || [ $n -lt 1 ]
	   then
		echo "1-4"
		continue
	fi
	if [ $n == 1 ]
	   then
		date
		continue
	elif [ $n == 2 ]
	   then
		ls
		continue
	elif [ $n == 3 ]
	   then
		who
		continue
	else
		pwd
		continue
	fi
   done
  • 升级版,改成显示数列,运算,显示颜色,发邮件程序
    颜色脚本
    https://blog.csdn.net/tanyyinyu/article/details/101051469
    邮件脚本
    https://blog.csdn.net/tanyyinyu/article/details/103081197
    https://blog.csdn.net/tanyyinyu/article/details/103187848
#! /bin/bash
while :
   do
	read -p "please name a number(1-4):" n
	if echo $n | grep -v '^[0-9]$' >> /dev/null
	   then
		echo "format wrong"	
		continue
	fi
	if [ $n -gt 4 ] || [ $n -lt 1 ]
	   then
		echo "1-4"
		continue
	fi
	if [ $n == 1 ]
	   then
		echo "i can count"
		sleep 2
		seq 1 100
		continue
	elif [ $n == 2 ]
	   then
		echo "i can calculate"
		sleep 2
		read -p "please input number1:" x
                read -p "please input number2:" y
		an=$(($x+$y))
		echo "sum is $an"
		continue
	elif [ $n == 3 ]
	   then
		echo "i can give you colour"
		sleep 2
		bash /root/colour.sh
		continue
	else
		echo "i can send you a email"
		sleep 2
		read -p "please input a email address:" m
		read -p "title:" t
		read -p "content:" c
		python /root/mail.py $m "$t" "$c"
		continue
	fi
   done
发布了125 篇原创文章 · 获赞 5 · 访问量 4626

猜你喜欢

转载自blog.csdn.net/tanyyinyu/article/details/103208707
今日推荐