Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 "foo.zip 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 greenwoodsoftware.com, 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!

share|improve this question
    
I found your answer via Google, and it wasn't easy. Glad I made it though! –  Adam Dec 13 '13 at 18:05
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
Configure how? Just set the $LESSOPEN variable? –  Daniel Beck Jan 12 '11 at 15:54
    
@Daniel: And making the script executable. –  Ignacio Vazquez-Abrams Jan 12 '11 at 15:56
    
Ah ha -- perfect! –  multihead Jan 12 '11 at 16:58
    
The script commonly used is lesspipe.sh. It's available via macports or directly from www-zeuthen.desy.de/~friebel/unix/lesspipe.html –  Doug Harris Jan 12 '11 at 16:59
add comment

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.

share|improve this answer
    
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 Apr 9 at 14:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.