Sometimes I find myself on a unix based system for the first time in awhile and I have to use the tar program to extract data from a tar or tar.gz compressed data set.
Here is a nifty set of helpful tips:
You can also extract files that match a specific pattern. This example shows how to extract files that start with psoft from the tar file psoft.tar regardless of its directory location:
$ tar -xf psoft.tar --wildcards --no-anchored 'psoft*'
To extract all xml files:
$ tar -xf psoft.tar --wildcards --no-anchored '*.xml'
Command Flags:
- -x: instructs tar to extract files.
- -f: specifies filename / tarball name.
- -v: Verbose (show progress while extracting files).
- -j : filter archive through bzip2, use to decompress .bz2 files.
- -z: filter archive through gzip, use to decompress .gz files.
- –wildcards: instructs tar to treat command line arguments as globbing patterns.
- –no-anchored: informs it that the patterns apply to member names after any / delimiter.
This post was sourced from article: Tar Extract a Single File(s) From a Large Tarball from CyberCiti