thnx you all for your kind help
my issue is that string will contain in more then one time
i managed some below
#/bin/bash
echo " Enter the DIR Path"
read dir
echo "File types"
read file
ls $dir | grep $file > flist
echo "enter the string"
read string
for line in `cat flist`
do
#a=" grep -c "1024" $line "
a=`grep -c "$string" $dir/$line`
if [ $a != 0 ]
then
#echo $a
echo "$line "
fi
done
kindly check this and let me know i want to make this more stable because
my txt file contain more then 500 lines (xml lines)
You do not want to call grep for every file, but sometimes there are too many files for "*.txt" to be either robust or low latency, so divide the find from the grep using xargs or parallel.
Use "grep -l" since you just want to list any presence not a -c count: