#!/bin/sh
#< Search through specified subdirectories without descent
# Usage: dirfind "searchterm|regex" /dir1 /dir2 /dir3 ... /dirn
# KW 08/10/04
if [ "$#" -lt "2" ]; then
echo "Usage: $(basename $0) \"searchterm\" /dir1 [/dir2 [.../dirn]]"
exit 1
fi
# this should be the column with the filename in it from output
# of ls -la
col=8
searchterm="$1"
shift
for dir in "$@"
do
# add a trailing slash - if the user has already done this
# it won't matter
dir=$dir/
match=$( ls -la ${dir} | awk -v c=$col '{print $c}' |\
grep "${searchterm}" )
if [ "$?" -eq "0" ]; then
echo "In Directory: ${dir}"
for file in $match
do
ls -la $dir$file
done
fi
done
exit 0