#!/bin/bash if [[ $# -ne 2 || ! -d $1 || ! -d $2 ]] then echo "usage: $0 directory1 directory2" exit 1 fi dir1=$1 dir2=$2 numPerLine=5 filelist=`mktemp` tmpdir=`mktemp -d` # TO DO: use your Java program and save the output to filelist numlines=`cat $filelist | wc -l` i=1 numRight=0 numTotal=0 while [ $i -le $numlines ] do # TO DO: Put the ith line of filelist in a variable (maybe use sed) # TO DO: Print out the variable holding the line # TO DO: increment i # TO DO: For each file named in the line, move it from dir1 to tmpdir # TO DO: For each file in tmpdir: # Increment numTotal # Run spam_detector on it with dir1 and dir2, save the result in a variable # Print out the result of running spam_detector # If the file is closer to dir1, increment numRight # (use grep and its exit code) # TO DO: For each file named in the line, move it from tmpdir to dir1 done echo "number right: " $numRight " number total: " $numTotal rm $filelist rmdir $tmpdir