Viewing zip archive contents using 'less' on OS X



I couldn't help but notice that the 'less' program on all of the recent distributions of Linux that I've used (Ubuntu and Gentoo in this case) allow me to view the contents of ZIP and TAR archives, while the install of 'less' that I have on OS X (and Solaris) instead produce a " may be a binary file. See it anyway?", which proceeds to spit out the raw binary data instead of a nice file structure listing.

Google has not produced much in the way of helpful results -- it's tricky to search for 'less' in this context. I downloaded and built the latest version from, but even it refuses to show the contents of these archives. I didn't come across any related configure/build options either. Any ideas? Thanks!


Posted 2011-01-12T15:40:19.080

Reputation: 43

I found your answer via Google, and it wasn't easy. Glad I made it though! – Adam – 2013-12-13T18:05:15.610



less uses $LESSOPEN to point to a script that will preprocess the file being passed to less. In the case of a .zip file the script runs zipinfo against it, returning information about the archive. Copy the script from a Linux machine and configure your OS X machine to use it.

Ignacio Vazquez-Abrams

Posted 2011-01-12T15:40:19.080

Reputation: 100 516

Configure how? Just set the $LESSOPEN variable? – Daniel Beck – 2011-01-12T15:54:47.303

@Daniel: And making the script executable. – Ignacio Vazquez-Abrams – 2011-01-12T15:56:12.260

Ah ha -- perfect! – multihead – 2011-01-12T16:58:01.183

The script commonly used is It's available via macports or directly from

– Doug Harris – 2011-01-12T16:59:52.927


In OS X I suggest to directly install lesspipe. I did it using Macports, but you're free to use your preferred method.

sudo port install lesspipe

To use lesspipe, set this in your .bash_profile:

export LESSOPEN='| /opt/local/bin/ %s'


Posted 2011-01-12T15:40:19.080

Reputation: 308

1Needs a single quote on the end. export LESSOPEN='| /opt/local/bin/ %s' – Adam – 2015-06-03T16:59:53.653


On Linux systems zless and zmore can show gzip compressed files (and old compress .Z files too, but you rarely see those now).

That's not exactly what you're asking though. A gzip compressed file is just a single file, compressed. A Zip file is collection of files and metadata. I'm not sure how you'd navigate the zip file with less. How do you do symlinks? How do you show the file metadata? I'm not saying it doesn't exist, but I haven't seen it, and i'm not sure what it would look like on OSX, which is even more graphical than most Linuxes.

Rich Homolka

Posted 2011-01-12T15:40:19.080

Reputation: 27 121

I don't know if it came with Mavericks or I somehow installed it myself, but I have zless in /usr/bin/ on OS X 10.9.2. – Daryl Spitzer – 2014-04-09T14:09:09.200