例1
例2
#!/bin/bash read -p "Please input your birthday (MMDD,ex>0709): " bir now=`date +%m%d` if [ "$bir" == "$now" ]; then echo "Happy Birthday to you !!!" elif [ "$bir" -gt "$now" ]; then year=`date +%Y` total_d=$(($((`date --date="$year$bir" +%s`-`date +%s`))/60/60/24)) echo "your birthday will be $total_d later" else year=$((`date +%Y`+1)) total_d=$(($((`date --date="$year$bir" +%s`-`date +%s`))/60/60/24)) echo "your birthday will be $total_d later" fi
例3
例4
#!/bin/bash accounts=`cat /etc/passwd|cut -d: -f1` for account in $accounts do declare -i num=$num+1 echo "the $num account is \"$account\"" done