Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Look inside pkg files without expanding them UNIX

Have you ever wondered about an easy way to know what is in a .pkg file without decompressing it? One solution was to use Pacifist, but it has gone shareware now. Besides, there is an easier solution with the Terminal. Drag your .pkg file on the Terminal icon in the dock while pressing the command and option keys. In the newly opened window type:

  % cd Contents/Resources
  % ls

One of the files should have a name ending with .pax.gz. Assume it is called archive.pax.gz, issue the command

  % gzip -cd archive.pax.gz | pax

VoilĂ ! You have the contents of the archive displaying in your window. Simple but good to know. A similar means of finding out what's inside a .tgz, .tar.gz or .tar file is to use one of these commands:

  % tar tvzf file.tgz
  % tar tvzf file.tar.gz
  % tar tvf file.tar
Obviously, choose the command based on the extension (the t flag tells tar to just list the archive's contents). Hope this helps!
  • Currently 1.25 / 5
  You rated: 2 / 5 (4 votes cast)

Look inside pkg files without expanding them | 8 comments | Create New Account
Click here to return to the 'Look inside pkg files without expanding them' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
alternative using lsbom
Authored by: hayne on May 01, '03 11:33:05AM

An alternative way is to look at the "bill of materials" contained
in the ".bom" file. (Thanks to the forums' "mervTormel" for the
idea.) Here's a script that does that (I made it executable and
saved it as 'lspkg' in my ~/bin folder):


# This script lists the "bill of materials"
# for the pkg file specified as a command-line argument.

if [ $# -lt 1 ]; then
scriptname=`basename $0`
echo "Usage: $scriptname pkg_file"

bom_files=`find $pkg_path -name '*.bom' -print`
for bom_file in $bom_files
lsbom $bom_file

[ Reply to This | # ]
Authored by: Krioni on May 01, '03 02:28:42PM

Hmm. lspkg does not work with paths that are escaped to work
in the shell, and doesn't seem to allow you to quote a file, either.
Spaces always break it. Anyone got a fix?

[ Reply to This | # ]
Authored by: mervTormel on May 01, '03 02:31:42PM

double-quote all the $var references, i.e.,


[ Reply to This | # ]
Problems with dragging to Terminal
Authored by: infinil on May 01, '03 06:58:39PM

I'm not sure if i'm the only one that has been having trouble
with this hint, but I can't get past the first step of cmd-opt-
dragging the file to the terminal icon. All this is doing is
opening a Terminal at the default location ~ home.

I'm guessing that it should be putting the directory location of
the file as your new directory location in the terminal, but not on
my system with 10.2.5.

Is it just me? Are there others that are having the same

- Dan

[ Reply to This | # ]
Problems with dragging to Terminal
Authored by: hayne on May 02, '03 01:09:17AM

I have no idea what the original hint expected to happen when
you opt-cmd drag the file to the Terminal icon in the dock. It
certainly doesn't work for me either.
I think most readers have been ignoring that part of the hint and
just using the Terminal to go to where the pkg file is.

[ Reply to This | # ]
Problems with dragging to Terminal
Authored by: iroot on May 02, '03 07:19:53PM

I think what the original tip meant was to type cd in Terminal
and then drag the package into the Terminal window.

[ Reply to This | # ]
Problems with dragging to Terminal
Authored by: chtito on May 03, '03 03:33:02PM

Well... On my mac (with 10.2.5) dragging any folder or bundle
while holding cmd-opt to the Terminal icon in the Dock opens a
new Terminal window with its path set to the the dragged
folder's path. Very convenient.

I thought that this was the normal behaviour... I'm not the only
one benefitting from this great feature, am I?

[ Reply to This | # ]
Look inside pkg files without expanding them
Authored by: gatorparrots on May 01, '03 11:12:46PM
These types of scripts have been written before:
StaticInnerClass/testuser published his whichbom script here:
for file in `ls /Library/Receipts/` 
  exists=`lsbom -p sfMUG /Library/Receipts/${file}/Contents/ 2> /dev/null | egrep "$1" ` 
  if [ -n "$exists" ]; then 
    echo "Found in ${file}:" 
    echo "$exists" 
    echo "" 
Usage: to find the parent package of a file:
whichbom `which command`
And the inimitable Gary Kerbaugh has his pkggrep script here:

"It's been way to long since I've done a shameless ad. Did you use my pkggrep script? If not, you might want to check it out. For the most, searching a single package receipt is a one-liner and searching all of them, a short loop. However, the creator of Pacifist suggested a number of options that might be useful. Thus, it's a little bloated but allows you customize your search quite a bit. Anyway, if you don't have it, you should at least look at it; any suggestions would be greatly appreciated!"

[ Reply to This | # ]