#!/bin/sh # # Roundabout way of doing 'grep string files' # # 1st argument: string to be searched for # 2nd argument: wildcard specification for group of files # # Pick up the search string # string=$1 echo Searching for string : $string # # Shift arguments to loose the search string shift # # Loop over all files # Check error status of grep to decide if string has been located ls $* | while read line do grep -l "$string" $line > /dev/null if [ $? = 0 ] then echo File : $line grep "$string" $line echo fi done