#! /bin/csh -f # script to do matching on courses: names etc. set home = ~steve set dir = public_html/wsearch set data = courses3.data set date = courses.date set query = courses.query set out = courses.results set tmp = courses.tmp cd $home cd $dir if ($#argv < 1) then echo 'course needs a search string argument.' exit endif /bin/ls -l $data | \ perl -n -e '@_ = split(/\s+/); print "$_[5] $_[6]\n";' > $date # get hits; add small font to last col. egrep -i "$1" < $data | perl -p -e 's/[^\t]*$/$&/;' > $tmp #egrep -i "$1" < $data > $tmp # Count lines, and print that as first word of result (part of table title) perl -e '$x = 0; while (<>){' -e '$x += tr/\n//;' -e '}; print "$x";' \ < $tmp > $out echo " search results for '$1'" >> $out # Table title echo "Course title Code Dept." >> $out # Column headings cat $tmp >> $out; rm -f $tmp wskel courses echo 'Now refresh page http://www.psy.gla.ac.uk/~steve/wsearch/courses.html' exit The GQL query gets code,title, dept-name of course. ("ListAllCourses") Sort by dept, then by course title. Print title,code,dept in that order. There are some duplicates: use "group"? Processing of a new data file from GQL: a) crlf -d ? a2) get rid of empty lines (actually, file seemed to have both CR and LF) c) uniq to get rid of duplicates d) Correct script 'course' to use right data file ("courses.65") give right col headers in right order.