zc
#!/bin/bash
s="$1"
shift
if [ -e "$s" ]; then
echo "$s already exists, skipping"
exit 1
fi
if [[ "$s" =~ \.tar\.(xz|gz|bz2) ]]; then
echo "Creating $s with tar (compression)"
tar cvaf "$s" "$@"
elif [[ "$s" =~ \.tar$ ]]; then
echo "Creating $s with tar (uncompressed)"
tar cvf "$s" "$@"
elif [[ "$s" =~ \.zip$ ]]; then
echo "Creating $s with zip"
zip -9r "$s" "$@"
elif [[ "$s" =~ \.(7z)$ ]]; then
echo "Creating $s with 7z"
7z a "$s" "$@"
else
echo "Unrecognised extension $s"
fi
zf
#!/bin/bash
for s; do
if [ ! -e "$s" ]; then
echo "$s does not exist, skipping"
continue
fi
if [[ "$s" =~ \.tar\. ]] || [[ "$s" =~ \.tar$ ]]; then
tar tf "$s"
elif [[ "$s" =~ \.zip$ ]]; then
zip -v "$s"
elif [[ "$s" =~ \.(7z|rar)$ ]]; then
7z l "$s"
fi
done
zx
#!/bin/bash
for s; do
if [ ! -e "$s" ]; then
echo "$s does not exist, skipping"
continue
fi
if [[ "$s" =~ \.tar\. ]] || [[ "$s" =~ \.tar$ ]]; then
a="${s%.*}"
a="${a%.tar}"
f="$(readlink -f "$s")"
(
mkdir -p "$a"
cd "$a"
tar xvf "$f"
)
elif [[ "$s" =~ \.zip$ ]]; then
a="${s%.zip}"
unzip -d "$a" "$s"
elif [[ "$s" =~ \.(7z|rar)$ ]]; then
a="${s%.*}"
7z x -o"$a" "$s"
fi
done