Practice 2, write a script/root/bin/yesorno.sh, prompt the user to enter Yes or no, and determine whether the user entered Yes or no, or other information #!/bin/bash # case $1 in yy]| [YY] [EE] [Ss]) echo "You put a $1" ;; [nn]| [NN] [Oo]) echo "You put a $1" ;; *) echo "Ukown" ;;     ESAC   ESCA3, write a script/root/bin/filetype.sh, determine the user input file path, display its file type (normal, directory, link, Other file types) #!/bin/bash # read -p " Please input a file " FILE if [ -h $FILE ] ; then echo "filetype is symolink file " elif [ -d $FILE ] ;then echo "Filetype is directory" elif [ -f $FILE ] ; then echo "Common file." else echo "Filetype is other " fi4, write a script/root/bin/checkint.sh, determine whether the user input parameter is a positive integer #!/ bin/bash # if [[ $1 =~ ^0*[1-9][0-9]*$ ]] ;then echo "You have input a zhengshu" else echo "Wrong" fi
This article from "Mylinux" blog, declined reprint!
Shell script exercises Basic Article 2