#!/bin/bashecho-e"Your name is ==> $(whoami)"echo-e"The current directory is ==> $(pwd)"
请自行创建一支程序,该程序可以用来计算“你还有几天可以过生日”啊?
#!/bin/bashread-p"Pleas input your birthday (MMDD, ex> 0709): "birnow=`date+%m%d`if [ "$bir"=="$now" ]; thenecho"Happy Birthday to you!!!"elif [ "$bir"-gt"$now" ]; thenyear=`date+%Y`total_d=$(($((`date--date="$year$bir" +%s`-`date+%s`))/60/60/24))echo"Your birthday will be $total_d later"elseyear=$((`date+%Y`+1))total_d=$(($((`date--date="$year$bir" +%s`-`date+%s`))/60/60/24))echo"Your birthday will be $total_d later"fi
让使用者输入一个数字,程序可以由 1+2+3... 一直累加到使用者输入的数字为止。
#!/bin/bashread-p"Please input an integer number: "numberi=0s=0while [ "$i"!="$number" ]doi=$(($i+1))s=$(($s+$i))doneecho"the result of '1+2+3+...$number' is ==> $s"