Back

rox的解压缩shell脚本

|

`#!/bin/sh
case "$TERM" in
xterm* | screen ) head="" ;;
* ) head="xterm -e" ;;
esac
for args in $@
do
fname=$(readlink -f "$args")
bname=$(basename "$fname")
dname=$(dirname "$fname")
dest1st=${bname%.*}
dest2nd=${dest1st%.*}
destdir=${dest1st}
case "$bname" in
*.tar.gz | *.tar.bz2 ) destdir=${dest2nd} ;;
esac
if [ ! -w "$dname" ]; then
$head "echo Permission denied && sleep 2"
exit 1
elif [ -d "$dname/$destdir" ]; then
$head "echo Directory already exists && sleep 2"
exit 1
else
cd "$dname"
mkdir "$destdir"
cd "$destdir"
case "$bname" in
*.tar.bz2 | *.tbz | *.tb2 | *.tbz2) $head tar xvjf "$fname" ;;
*.tar.gz | *.tgz) $head tar xvzf "$fname" ;;
* ) $head 7z x "$fname" ;;
esac
fi
cd "$dname"
done
exit 0`

No comments yet

Leave a comment

About me

I live in Tasmania, an island a little far from the rest of the world and very close to the sea.
Father of two little girls, have two puppies.

Work

Work in IT industry, AI is my working partner.