tar -t: List Archive Contents (Usage & CI Errors)
tar -t lists what is inside an archive without writing anything to disk.
Listing is the safe way to inspect an artifact before extracting it: you confirm the paths, the top-level prefix, and whether it is even a tar archive.
What it does
tar -t (list) reads the archive and prints the name of each member. Nothing is extracted. Adding -v prints a long listing with permissions, owner, size, and mtime, similar to ls -l.
Common usage
tar -tf archive.tar
tar -tvf archive.tar.gz # long listing with metadata
tar -tzf archive.tar.gz | head # peek at the first members
tar -tf archive.tar 'src/*' # list only matching membersOptions
| Flag | What it does |
|---|---|
| -t / --list | List the contents of the archive |
| -f <file> | Read from <file> instead of stdin |
| -v / --verbose | Long listing with mode, owner, size, and date |
| -z / --gzip | Force gzip decompression (usually auto-detected) |
In CI
Before extracting a cache or release, tar -tf archive.tar.gz | head confirms the top-level layout. If members start with a versioned prefix like app-1.2.0/, you know to pass --strip-components=1 on extract.
Common errors in CI
tar: This does not look like a tar archive followed by tar: Exiting with failure status due to previous errors means the file is not a tar archive (a zip, a raw binary, or an error page). gzip: stdin: not in gzip format on a -tz call means the file is not gzip-compressed; list without -z or check what was actually downloaded.