#!/bin/bash
declare -x mark=unquit
while [ “${mark}” != “quit” ]
do
echo -en “enter (copy) to copy a file.\nenter (settings) to print the settings.\nenter (gus) to have a game guess a number 0-9.\nenter (date) to show the second right now.\nenter (diary) to write today’s things at diary after read.\nenter (set) to set new diary route or read your old diary.\nenter (none) read y to quit.\n”
read -p "so enter a str to use function: " vary
case ${vary} in
"copy")
read -p "enter the file name in absolute path:" path1
read -p "enter the aim path" path2
cp -a path1 path2
;;
"settings")
echo "YOUR home catalogue: "
echo -n $HOME
echo "--------------------------------------"
echo "YOUR shell: "
echo -n $SHELL
echo "--------------------------------------"
echo "YOUR route right now: "
echo -n $PWD
echo "--------------------------------------"
echo "YOUR username: "
echo -n $USER
echo "--------------------------------------"
echo "TIME: "
date
;;
"gus")
read -p "enter a number: " nm
declare -i number=$RANDOM*10/32768
[ "$nm" == "$number" ] && echo "RIGHT!!" || echo "YOU are wrong,the number is $number"
;;
"date")
echo $(date +%s)
;;
"diary")
read -p "START to write now! " diary
echo $(date) >> $path_diary
echo $diary >> $path_diary
cat -An $path_diary
;;
"set")
read -p "enter R to read one,S to set one: " DIARY
case $DIARY in
"R")
echo "--help:the path is /home/work/diarys/(your diary name)"
read -p "enter the absolute path:" path_diary
declare -x path_diary
;;
"S")
read -p "enter the diary name:" filename
touch /home/work/diarys/$filename
echo "set success! enter set again to read the diaryname you just creat!"
;;
"*")
echo "wrong arr!"
exit 1
;;
esac
;;
"none")
echo "ready to quit"
;;
"*")
echo "WRONG!"
exit 1
;;
esac
read -p "enter quit to end,enter unquit to continue: " mark
done