Either using
tar -tf archive.tar
OR
tar --list -f archive.tar
Doesn't show the trailing slash that corresponds to a dir, making
impossible to know if the content is a directory or a file without
having to use verbose output.
Example: get the contents of a tar archive to a text file:
tar --list -f myarchive.tar
dir1
dir1/data.dat
Where it should be
dir1/
dir1/data.dat
So I can filter either directories or files:
Only files: tar -tf archive.tar | grep -v /$ > files.txt
Only directories: tar -tf archive.tar | grep /$ > directories.txt