Shell programming languages are unfit for processing files.
Unless all your files are in one directory, Bash, Windows cmd, and PowerShell programming are likely the wrong tool for the job. Looping through files - or piping find and xarg results - forces you to rescan the filesystem for each pass, has problems for many corner cases (including spaces in filenames and premature wildcard expansion), runs slowly because they don't use indexes, is tortuous when combining multiple search criteria, basic arithmetic on results is painful, and comparing one set of files with another is a headache.
Type 'crab' at the command line to get a Crab prompt powered by SQL. Crab scans the directories you specify and gives you an indexed table, files, that holds information about the files and directories, and a virtual table, fileslines, that gives you SQL access to file contents.
Scans run at several thousand files per second, so scanning a bunch of project or data directories usually takes no more than a second or two. The whole of a spinning disk 1TB drive takes about 30 minutes, SSDs are much faster. Most people scan project directories on demand, and the whole disk once a week or so - you can have multiple scan databases.
Free for non commercial use