#! /bin/bash #+ # NAME: # search # PURPOSE: # Roundabout way of doing 'grep string files' # CALLING SEQUENCE: # search "string" wildcard # INPUTS: # string string to be searched for # wildcard wildcard specification for group of files # MODIFICATION HISTORY: # Paul Hick (UCSD/CASS; pphick@ucsd.edu) #- # Pick up the search string string=$1 # 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