Hi.
I rarely use zip / unzip, but it worked for me as expected. This script creates a structure, zips it, renames the old directory, unzips from the archive, and compares the 2 resulting directory structures:
Code:
#!/usr/bin/env bash
# @(#) s1 Demonstrate zip collection and expansion of directories.
# ____
# /
# | Infrastructure BEGIN
echo
set -o nounset
debug=":"
debug="echo"
## The shebang using "env" line is designed for portability. For
# higher security, use:
#
# #!/bin/sh -
TREE=tree
TREE=dtree
TREE=tree-sage
## Use local command version for the commands in this demonstration.
set +o nounset
LC_ALL=C ; LANG=C ; export LC_ALL LANG
echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1) zip diff
set -o nounset
echo
# Remove and create directory structure.
rm -rf d1 d2 d1.zip old-d1
mkdir -p d1/d2/d3
echo hi >d1/hi-in-d1
echo hi >d1/d2/hi-in-d1-d2
echo hi >d1/d2/d3/hi-in-d1-d2-d3
echo " Directory to be zipped:"
$TREE ./d1
# | Infrastructure END
# \
# ---
echo
echo " Results from processing:"
zip -r d1 d1
ls -go d1.zip
echo
echo " Unzipping:"
mv d1 old-d1
unzip d1
echo
echo " Newly unzipped d1:"
$TREE d1
echo
echo " Old d1:"
$TREE old-d1
echo
echo " Comparison of d1 and old-d1:"
CMP="diff -r"
if $CMP d1 old-d1
then
echo " Directories d1 and old-d1 have the same content."
else
echo " Directories d1 and old-d1 fail to compare."
fi
exit 0