#! /bin/tcsh
#
# Run version of find program given in $1, sending output to dir given in $2.
# Default for $1 is ./find.  Default for $2 is ./output.
#

if ($1 == "") then
    set find_prog = ./sfind
else
    set find_prog = $1
endif

set find = "~gfisher/classes/357/bin/timelimit 10 $find_prog"

if ($2 == "") then
    set outdir = ./output
else
    set outdir = $2
endif

#
# Set referenced paths.
#
set path1 = /home/gfisher/classes/357/labs/2
set path2 = /home/gfisher/work/fmsl
set path3 = /home/gfisher/classes/357/labs/2/javadoc
set path4 = /home/gfisher/projects/CVS/fmsl/subprojects/eclipse/documentation/latex


#
# Run the test cases, which are subdivided into primary groups.
#

# just printing, 10 pts subtotal
$find $path1 > $outdir/default.out
$find $path1 -print > $outdir/print.out

# -atime, 4 pts subtotal
$find $path2 -atime 1 > $outdir/atime-1.out
$find $path2 -atime 2 > $outdir/atime-2.out
$find $path2 -atime 3 > $outdir/atime-3.out
$find $path2 -atime 50 > $outdir/atime-50.out

# -ctime, 4 pts subtotal
$find $path2 -ctime 0 > $outdir/ctime-0.out
$find $path2 -ctime 9 > $outdir/ctime-9.out
$find $path2 -ctime 85 > $outdir/ctime-85.out
$find $path2 -ctime 10 > $outdir/ctime-10.out

# -mtime, 4 pts subtotal
$find $path2 -mtime 0 > $outdir/mtime-0.out
$find $path2 -mtime 1 > $outdir/mtime-1.out
$find $path2 -mtime 10 > $outdir/mtime-10.out
$find $path2 -mtime 50 > $outdir/mtime-50.out

# -user, 4 pts subtotal
$find $path3 -user gfisher > $outdir/user-gfisher.out
$find $path4 -user jenglert > $outdir/user-jenglert.out
$find $path2 -user root > $outdir/user-root.out

# -group, 4 pts subtotal
$find $path3 -group faculty > $outdir/group-faculty.out
$find $path4 -group cscstd > $outdir/group-cscstd.out
$find $path2 -group root > $outdir/group-root.out

# -newer, 4 pts subtotal
$find $path1 -newer $path1/Makefile > $outdir/newer-Makefile.out
$find $path1 -newer $path1/javadoc > $outdir/newer-javadoc.out
$find $path1 -newer $path1/../index.html > $outdir/newer-index.out

# -type, $outdir/4 subtotal
$find $path1 -type d > $outdir/type-d.out
$find $path1 -type f > $outdir/type-f.out
$find $path1 -type l > $outdir/type-l.out
$find $path1/images -type l > type-l-2.out

# -size, 8 pts subtotal
$find $path1 -size 1 > $outdir/size-1.out
$find $path1 -size 2 > $outdir/size-2.out
$find $path1 -size +10 > $outdir/size-+10.out
$find $path1 -size -2 > $outdir/size--2.out

# -name, 10 pts subtotal
$find $path1 -name GeneralList.java > $outdir/name-Gen.out
$find $path1 -name '*.html' > $outdir/name-star.html.out
$find $path1 -name 'G*.*' > $outdir/name-Gstar.star.out
$find $path1 -name 'G*.*l' > $outdir/name-Gstar.star-l
$find $path1 -name '??' > $outdir/name-ques-ques.out
$find $path1 -name '*.o' > $outdir/name-star.o.out
$find $path1/../../solutions/labs/2 -name '*.?' > $outdir/name-star-ques.out
$find $path1/../../solutions/labs/2 -name '?e?e*.o' > $outdir/name-ques-e-ques-e-star.out
$find $path2 -name '*.doc' > $outdir/name-star.doc.out
$find $path2 -name '??' > $outdir/name-ques-ques.out

# -exec, 12 pts subtotal
$find $path1 -exec ls -sal {} \; > $outdir/exec-ls-sal.out
$find $path1 -exec grep -n newGeneralList {} \; > $outdir/exec-grep.out
$find $path1 -exec grep -n newGeneralList {} > $outdir/exec-grep-2.out \;

# not, 8 pts subtotal
$find $path1 \! -newer $path1/Makefile > $outdir/not-newer-Makefile.out
$find $path1 \! -name $path1/Makefile > $outdir/not-name-Makefile.out
$find $path1 \! -type f > $outdir/not-type-f.out
$find $path1 \! -size +10 > $outdir/not-size-+10.out

# multiple actions, 24 pts subtotal
$find $path1 -newer $path1/Makefile -name '*.c' > $outdir/multiple-1.out
$find $path1 -name '*.c' -newer $path1/Makefile > $outdir/multiple-2.out
$find $path1 -exec grep -n newGeneralList {} \; -print > $outdir/multiple-3.out
$find $path1 -exec grep -n newGeneralList {} \; -exec ls -sal {} \; > $outdir/multiple-4.out
$find $path1 \! -newer $path1/Makefile -type f -size +10 -exec grep -nl swap {} \; > $outdir/multiple-5.out
$find $path2 -atime 0 -ctime 0 -mtime 0 -user gfisher \! -group cscstd -newer $path2/administration/LOG -type d -size -20 \! -name CVS -exec find {} -name 's*.c' \; > $outdir/multiple-6.out
