Linux:写一个与电脑玩石头剪刀布的脚本
2020-08-07 19:47
281 查看
人机石头剪刀布
#!/bin/bash echo "Choice the numbers!" read -p "Made your choice rock:1 paper:2 scissors:3 : " Choice #echo $Choice if [[ $Choice =~ [123] ]]; then computer=$[ $RANDOM%3+1 ] # echo $computer if [ $Choice -ne $computer ]; then if [ $Choice -eq 1 ]; then [ $computer -eq 3 ] && echo "Computer is scissors. YOU WIN!" && exit || echo "Computer is paper. YOU LOSE!" && exit fi if [ $Choice -eq 2 ]; then [ $computer -eq 1 ] && echo "Computer is rock. YOU WIN!" && exit || echo "Computer is scissors. YOU LOSE!" && exit fi if [ $Choice -eq 3 ]; then [ $computer -eq 2 ] && echo "Computer is paper. YOU WIN!" && exit || echo "Computer is rock. YOU LOSE!" && exit fi fi echo "Tie!" fi echo "You gotta follow my tips like rock:1 paper:2 scissors:3."
玩起来!
相关文章推荐
- 一个小白的linux学习历程(1)——第一个脚本
- linux下用脚本实现:监控一个进程,不存在则将其启动。
- Linux 一个sysv 脚本参考模板
- Pixhawk原生固件PX4之一个脚本搞定Linux系统的环境配置
- 一个修改linux hosts文件上google的脚本
- linux下设计一个Shell脚本:求命令行上所有整数和
- 当一个会修改密码的人坐在你的电脑前(linux)~~~~·
- linux脚本的编写和执行,很简单的一个用法!
- [Unix/Linux] catsrc.sh: 此脚本用于在写报告时把项目的多个源代码文件方便的 `cat` 到一个文件上, 并把来自不同的文件之间加上一个标识头以区分输出文件里的不同文件
- Linux /sbin/service脚本一个基本无影响的bug
- 一个php写的linux下lvm自动快照实现脚本
- Linux---分享一个有关dig的实用脚本
- 朋友的一个问题:Linux开机如何自动运行自己编写好的shell脚本
- 一个Linux中用于监控的简易shell脚本
- 一个Linux下Mysql备份脚本,可用于crontab定时任务
- Linux下实现一个简单进度条和shell脚本实现彩色进度条
- linux 一个获取天气预报的脚本
- 是一个设计将LinuxFreak.org新闻标题放置到你的网站的PHP脚本程序。
- 刚学习时自己写的一个linux系统初始化脚本
- 在 Linux 环境下,编写一个非常实用的删除小脚本