此腳本不完整,因爲我稍後想要做錯誤測試,但想法是ARG是腳本,ARG2是目錄,ARG應標記ARG2中的所有文件。我該如何做到這一點,讓bash知道第一個參數必須是腳本,而參數2是一個目錄?將腳本作爲參數傳遞Bash
ARG=$1
ARG2=$2
CHECK=0
aCount=0
bCount=0
cCount=0
dCount=0
fCount=0
if [ $CHECK -e 0 ]; then
for files in $ARG2; do
if [ sh $1 $2 -eq A]; then
aCount=$((aCount+1))
elif [ sh $1 $2 -eq B];
bCount=$((bCount+1))
elif [ sh $1 $2 -eq C];
cCount=$((cCount+1))
elif [ sh $1 $2 -eq D ];
dCount=$((dCount+1))
else;
fCount=$((fCount+1))
fi
done
fi
echo A: $aCount
echo B: $bCount
echo C: $cCount
echo D: $dCount
echo F: $fCount
沒關係,我想通了。非常感謝你:) – DrJessop