#!/bin/bash # There is little data security here, so know what you're doing. # All risks in using this code are yours. It moves and deletes files quite stupidly. # (c) Daniel Lange, 2009, v0.01, released into the public domain if [ $# -ne 1 ] ; then echo "Error: $0 expects exactly one argument, a (fully qualified) path/to/a/zipfile" exit 1 fi if [ ! -r $1 ] ; then echo "Error: file does not exist or no read permission on $1" exit 2 fi if [ ! -w "$(dirname $1)" ] ; then echo "Error: cannot write to directory of $1" exit 3 fi if [ "$(head -c 2 $1)" == "PK" ] ; then mv $1 $1.tmp mkdir -p $1 unzip -d $1 $1.tmp rm $1.tmp else echo "$1 is not a zipfile" fi