#!/bin/csh -f # #20apr98# cntword: count # of times a word appears in a file or in all of ./ #..usage: cntword word # set word = "$1" set file = "$2" if( "$1" == "" ) then echo -n "--- cntword word file --- Enter word(string): " set word = $< endif if( "$2" == "" ) then echo "" echo -n "--- cntword word file --- Enter file _OR_ blank(in all of ./): " set file = $< endif if( "$file" == "" ) then echo " --- counting $word in all of ./ ---" find . -print -exec grep $word {} \; | wc -l exit else grep "$word" $file | wc -l endif ### modified from: Unix Tip #475- April 20, 1998 ### http://www.ugu.com/sui/ugu/show?tip.today