Grepping within recursive tarballs
This utility function searches for a given pattern within recursive tarballs
Within a single tarball, this can be achieved using zgrep -a pattern archive.tar, for instance.
However, when a tarball may contain other tarballs, it can be more tricky to obtain
- parent.tar
- child1.tar
- subchild1-1.tar
- path/to/file1.text
- ...
- subchild1-2.tar
- ...
- subchild1-1.tar
- child2.tar
- subchild2-1.tar
- path/to/otherfile.text
- ...
- subchild2-1.tar
- folder/otherfile.log
- child1.tar
If searching for the string "ERROR" within any file contained in any of the tarballs, you would:
- Import the function:
source targrep.sh - Call the function:
targrep "ERROR" parent.tar
Inspired by the code shared on stackoverflow: http://stackoverflow.com/a/13042529/3690491