#!/bin/bash f1="$1*" f2="$2*" echo "第一個版本:"$f1 echo "第二個版本:"$f2 git log | grep "commit [0-9a-zA-Z]\{40\}"|awk 'BEGIN{count=0;} {commit[count]=$2;count++;} END{for(i=0;i<NR;i++) print i,commit[i]}' | grep -E "$f1|$f2" > result LineNum=`awk 'END {print NR}' ./result` if [ $LineNum -lt 2 ];then echo "版本號輸入錯誤,請檢查輸入的版本號" else num=`awk 'BEGIN{count=0;} {num[count]=$1;count++;} END{print sqrt((num[0]-num[1])*(num[0]-num[1]))+1}' ./result` echo "相差"$num"個版本" fi