#!/bin/tcsh -f #(ie run the tshell on this but don't read the .cshrc or .tcshrc) echo version = 1.02 of and 2010 Mar 13 # 2013 Mar 13, 1.02: allow 2 or 3 arguments # 2010 Mar 10, 1.01: ignore case with grep -i # 2008 Apr 4, 1.00: origin set source = ~/n/r/a if ($#argv < 2) then echo and [source file] [term 1] [term 2] echo 'Search (grep) source file paragraphs for two terms.' echo "If the source file is not given, it is assumed to be at" echo "$source" echo "The source file is formatted (by fmt) to make each paragraph" echo "into a single line. This is then searched twice with grep." exit endif if ($#argv == 2) then # default value for source set term1 = $1 set term2 = $2 else # logically there are three arguments set source = $1 set term1 = $2 set term2 = $3 endif echo "searching $source" set tmp1 = /tmp/`whoami`-1.and echo -n "formatting ..." cat $source |\ fmt -w 1000 |\ cat > $tmp1 echo " done" cat $tmp1 |\ grep -i $term1 |\ grep -i $term2 |\ grep '@' |\ sed 's/@/@/' |\ tr '' '\n' |\ # cut -c1-50 |\ fmt |\ cat