Something resembling this:
for srcfile in $(echo *.data) ; do
bn=$(basename $srcfile .data)
sinkfile={$bn}.txt
grep "something about $bn" srcfile >> sinkfile
done Assuming bash, but ksh should work also. The $(...) becomes `...` in sh (Bourne shell)
line 1: echo *.data works only if you are in the correct directory. You can also use find . *.data (but beware using basename in that case)
line 1: the trailing ; do can be removed and a solo do placed on the next line if you prefer that style
line 2: You will want to use bn=${srcfile%.data} so as to keep the path if you need to work multiple directories, use find or whatever
I believe the rest is 'obvious'?
Addendum: If the initial data is valuable or hard to recover, it is well to make a copy of the sinkfile then redirect the output onto the original, leaving a pristine copy available in case of trouble.Beware that if there is trouble you must first rename the copy to the original name before you try again. Yes, I still have scars...