#!/bin/bash test ! -f abc.txt && echo "Do Not Exist abc.txt" rm -rf abc.txt test ! -e abc && echo "Do Not Exist abc" rm -rf abc echo "131" > abc.txt echo "chaiyuan" >> abc.txt if [ $1 -lt 2 ] then echo "$1not" exit 0 fi n=0; num=0; for((i=2;i <= $1;i++)); do if [ $(($1%i)) -eq 0 ] #判断这个数与i取余是否等于0 then if [ $1 -ne $(($1%i)) ] #判断这个数与i取余是否等于本身 then #echo "$1不是质数" break fi else if [ $i -gt $(($1/2)) ] then # echo "$1是质数" n=1 break fi fi done mkdir abc if (("$n"=="1"));then echo "1" > abc/result.txt else echo "0" > abc/result.txt fi chmod a+x abc