The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-12-2008
keelba keelba is offline
Registered User
  
 

Join Date: Apr 2002
Location: Dallas, TX
Posts: 57
I would try something like this:

#!/usr/bin/ksh
for i in `ls *.txt`
do
grep "<STRING>" $i 1>/dev/null 2>&1
if [[ $? = 0 ]]
then
echo -n "${i}: "
grep -n "<STRING>" $i | awk -F: '{printf "%s",$1" "}'
fi
done
echo