Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Last active December 14, 2015 22:09
Show Gist options
  • Save ttscoff/5156628 to your computer and use it in GitHub Desktop.
Save ttscoff/5156628 to your computer and use it in GitHub Desktop.
A bash function that lists the contents of various types of archives. Easier to remember, faster to type.
# ls archives (inspired by `extract`)
lsz() {
if [ $# -ne 1 ]
then
echo "lsz filename.[tar,tgz,gz,zip,etc]"
return 1
fi
if [ -f $1 ] ; then
case $1 in
*.tar.bz2|*.tar.gz|*.tar|*.tbz2|*.tgz) tar tvf $1;;
*.zip) unzip -l $1;;
*) echo "'$1' unrecognized." ;;
esac
else
echo "'$1' is not a valid file"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment