Simple shell-script example and shell-script example
#! /Bin/bash # defind the pathPATH =/usr/localexport PATHread-p "please input your first name:" firstnamereap-p "please input your last name: "lastnameecho-e" \ nyour name is: $ firstname $ lastname "# use date create fileread-p" please input your filename: "fileuserfilename =$ {fileuser: -"filename"} # use date get the filenamedate1 =e1 (date -- date = '2 days ago '+ % Y % m % d) date2 = $ (date -- date = '1 days ago '+ % Y % m % d) date3 = $ (date + % Y % m % d) file1 =$ {filename }$ {date1} file2 =2 {filename }$ {date2} file3 =3 {filename }$ {date3} touch "$ file1" touch "$ file2" touch "$ file3" # conditional read-p "please input (Y/N): "ynif [" $ yn "=" Y "] | [" $ yn "=" y "]; then echo "OK continue" exit 0 fiif ["$ yn" = "N"] | ["$ yn" = "n"]; then echo "OK continue" exit 0fi # case 2 if [conditional attention]; then content else content fi #3 if [conditional attention]; then content elif [conditional attention]; then content else content fi # Use case... esac determines the case $ variable name in "first variable content") program segment; "second variable content") program segment ;;*) program Section (excluding the content of the first and second variables) exit 1; esac # example case $1 in "one") echo "This is one"; "two ") echo "this is two"; "three") echo "This is three"; *) echo "no number ";; esac # Use the function (shell script is executed from top to bottom, from left to right, so the function must be written in the front of the program) function printit () {echo-n "Your choice is "}