All commands tested on Mac OS Monterey / Jul 02, 2024

How to list the contents of a tar archive by filetype

List the contents of the files.tar tar archive by filetype.

You can use this short tar command.

              
                  tar -tvf files.tar --include '*.svg'
              
          

Or this more verbose tar command.

              
                  tar --list --verbose --file files.tar --include '*.svg'
              
          

The commands above will list only the *.svg files in the files.tar tar archive.


Options explained

  1. -t or --list tells tar to extract an existing archive
  2. v or --verbosetells tar to produce verbose output
  3. f or --filetells tar that the next parameter will be the tar file to create, extract, append to, list, etc.
  4. include tells tar to process files or directories that match the specified pattern

More commands to list the contents of tar archives