this post was submitted on 15 Sep 2025
23 points (92.6% liked)

Linux

14399 readers
85 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 3 years ago
MODERATORS
 

I made a small utility for listing the file names inside an archive file, e.g. tar, zip, etc. This comes in handy when you download some software package using the command line but you aren't sure whether to extract it in its own folder because you don't know what the file structure inside is.

all 14 comments
sorted by: hot top controversial new old
[–] sxan@midwest.social 16 points 10 months ago

Huh. tar tf and unzip -l. I'm not sure I'd even bother to write a shell function to combine them, much less install software.

Zips just exploding to files is so common, if you just mkdir unzpd ; unzip -d unzpd file.zip it's going to be right nearly all of the time. Same with tarballs always containing a directory; it's just so common it's barely worth checking.

You write the tools you need, don't get me wrong. This seems like, at most, a 10-line bash function, and even that seems excessive.

function pear() {
case $1 in
  *.zip)
    unzip -l "$1"
    ;;
  *.tar.*)
    tar tf "$1"
    ;;
esac
}
[–] RedSnt@feddit.dk 2 points 10 months ago

Nifty! I've recently begun using archivemount-ng, which allows mounting an archive of the formats you mention (not rar though, but I have rar2fs for that), and in theory one can easily mount an archive using those methods and just do a tree in the mount folder, but it seems that pear saves a few steps and makes that a lot easier.

[–] SinTan1729@programming.dev 2 points 10 months ago