I want to write a batch script that:
- Finds a filename
- The filename is inside a tar archive
- The tar archive is located in a different directory
- The filename matches a given pattern
I want to avoid untaring, if possible, and want to store the filename in a variable.
My tar file is located in
bar.tar.gz. Inside the tar archive, I want to get the filename of the file starting with
baz*, followed by some digits and an underscore (e.g.
So far, I know of the
find command, but it does not work when trying to access a tar file. I want something like this:
filename_in_question=$(find ./foo_tar/bar.tar.gz -name 'baz*')
Is there any workaround to this?