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.

  • 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
    }