this post was submitted on 15 Sep 2025
24 points (92.9% liked)

Linux

9406 readers
523 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 2 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.

you are viewing a single comment's thread
view the rest of the comments
[–] sxan@midwest.social 17 points 1 day 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
}