#!/bin/bash
#-------------------------
# Function.sh
# Version : 1.0
# Author : passion
# Date : Jan 13 2009
# Secification : The script accomplish searching the same model
#-------------------------
#cd "D:\LocalCVS\TDB_SDY_KCG\Factory_Tests\Test_Procedures"
# find out the csv file directory
file=`find . -type f -name "*.csv"`
if [ -z "$file" ]
then
echo "Error:the csv file don't exist!"
exit 1
fi
# search failed!
echo "the csv file is : $file"
result=`awk -F";" '{ print $3 }' $file |sort|uniq -d`
#result=`echo "$file" | cut -f 3 -d";"| sort |uniq -d`
#echo "$result"
result=( $(echo $result))
i=0
while [ "$i" -lt ${#result[@]} ]
do
#j=0
grep ";${result[$i]}" $file >temp
cut -f 1,3 -d";" temp
echo "---------------------------"
#line=( $(cat temp))
#while [ "$j" -lt ${#line[*]} ]
#do
#echo ${line[0]} | cut -f 1,3 -d";"
#let j++
#done
#awk -F";" '{ print $1,$2 }' $file
let i++
done
rm temp
#echo result|awk '{ i=1;while(i<NF) { print NF,$i,$1,$2,$3;i++}}'
#echo "the result is: $result"