This prints out the list of files inside the tarball matching the given pattern:
tar --ignore-command-error -xvf PROD_009_010919_0110.tar.gz --to-command="grep -FH 1234536 -" | grep -B1 --no-group-separator '(standard input)' | grep -v '(standard input)'
--to-command option extracts each file and sends to the standard input of the
grep command. The
-v option lists each file as they're processed.
--ignore-command-error is used to ignore the exit status when
grep cannot find a match. Because of the
-H option (print filename) used with the
grep command, each matching line is prefixed with a '(standard input)' string.
This results in output of the following kind from the
(standard input): <matched lines from file2>
(standard input): <matched lines from file3>
Piping this output allows the two
grep commands to extract only the file names which are immediately followed by the '(standard input)' string on the next line. This processing could probably be improved using a regex to match the pattern instead of the two sequential
grep commands I have used here.
The resulting output in this case will be: