Extracting
List the archive
tar -tf archive.tar.gz
Output
docs/
docs/readme.md
notes.md
path/to/file
Lists archive members. -t lists and -f names the archive; find the exact path before extracting. See GNU tar.
Extract one member
tar -xf archive.tar.gz path/to/file
Output
path/to/file
Extracts one archive member. -x extracts and -f selects the archive; pass the exact path. See GNU tar.
Print to stdout
tar -xOf archive.tar.gz path/to/file
Output
file contents
Prints a member to stdout. -O writes instead of creating a file. See GNU tar.
Match a pattern
tar -xf archive.tar.gz --wildcards '*.md'
Output
docs/readme.md
notes.md
Extracts members by glob. GNU tar needs --wildcards before it treats a name as a pattern. See GNU tar.
Related links
- GNU tar manual (gnu.org)
0 Comments for this cheatsheet. Write yours!