We have a process that is not running correctly. It is supposed to only run on files with patterns like "AAA*.x12". However, it is also running on files similar to "BBB*.x12" Each directory only contains an AAA type type or BBB type file. While there is an output.log that contains the data I am looking for, it does not contain the name of the file being processed.
Question: I want to grep a string in a filename in a large number of directories. However, I only want to look at directories that contain a second file matching a specific pattern.
In other words, how can I grep the output.log files only in directories that contain files starting with BBB, and ignore the output.log files in directories that contain files starting with AAA
Note: The directory names are sequential numbers and cannot be used to determine which type files they contain