5

csh grep analog

view full story
linux-howto

http://www.unix.com – Hi everyone, I'm trying to make a csh script analog for grep. I need to run through the directory which is arg[1], find a word (arg[2]) in the files, and echo their names. Here's what I got Code: if ($#argv != 2) then   echo "Usage: $0 directory word"   echo "Shows files which contains words"   exit 0 endif set dir = $argv[1] if (! -d "$dir") then   echo "$dir is not a directory"   exit 1 endif foreach file ($dir/*) if (! -d "$file") then   set arr = (`cat $file`)   set i = 0   while i <= $#ar (HowTos)