Dig and concatenate all files yesterday then save it to another directory

I dont want to use for loop since it is using a lot of resources especially to a thousand files. Wanting to have a while? or something will find files that has been modifed or created yesteraday. View it. And search for soemthing and save it to a certain folder.

for i in `find ./ -mtime -1|grep FILESINEED |head -1`; do VIEWBINARY $i   ; done

I can do that. But if Im gonna do this..

#find ./ -mtime -1|grep FILESINEED |head -3
./data/deep/12/3/files1
./data/deep/1/aaaaa/3/files2
./data/deep/haha/cant/save/fhard/files3

#for i in `find ./ -mtime -1|grep FILESINEED |head -1`; do VIEWBINARY $i |grep -e COM e -NET -e GOV   > /tmp/$i.log ; done


Expected Output:
/tmp/net/files1.log
/tmp/gov/files2.log
/tmp/com/files3.log

It will not save it since the find output

I guess this is an else statement? I need help here. I will have a find and a loop statement. That will look for a file that contains NET in the file and will move it to net directory. Same goes with COM. I can run this 1 by 1 or create 3 commands. But the disadvantage of this. It will run again to the files that already been scan.
Thanks

It is a bit confusing. For example, what is FILESINEED? What is VIEWBINARY?
Perhaps the following puts you on the right track?

for i in `find ./ -mtime -1 | grep FILESINEED`
do
  case `VIEWBINARY "$i"` in
  ( *COM* ) dest=com;;
  ( *NET* ) dest=net;;
  ( *GOV* ) dest=gov;;
  esac
  echo mv "$i" "/tmp/$dest/$i.log"
done
2 Likes

the viebinary could be the string command or any application command that can view a a binary file.
Thank you

--- Post updated at 09:57 PM ---

grep -e COM e -NET -e GOV # this is what im referring to filesineed.

--- Post updated at 10:15 PM ---

Hmmmmm Almost but not quite.. The script will run, after it will search for the file for the

#For the code below, I am hoping example after string $i, i want to grep the file,. I want to know the file if it contains COM or NET or GOV, then it will move it to destination folder. But it did not happen, Also Theres an error as well aside it doesnt search for the thing. Please see below.

for i in `find ./ -mtime -1 |head -30| grep datalog`
do
  case `string "$i"` in
  ( *COM* ) dest=com;;
  ( *NET* ) dest=net;;
  ( *GOV* ) dest=gov;;
  esac
  echo cp "$i" "/tmp/$dest/$i.log"
done




The ERROR:
cp ./59/a8/9dd-225e-005056be5b.datalog /tmp/com/./59/a8/9dd-225e-005056be5b.datalog.log