You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

98 lines
1.5 KiB

#!/bin/bash
function descompressor()
{
case $1 in
*.tar)
tar -xvf $1
;;
*.tar.gz)
tar -xzvf $1
;;
*.tar.bz2)
tar xjf $1
;;
*.bz2)
bzip2 -d $1
;;
*.tgz)
tar -zxvf $1
;;
*.gz)
gzip -d $1
;;
*.zip)
unzip $1
;;
*.7z)
7za e $1
;;
*)
echo "Extent not found"
;;
esac
echo ""
echo "Done"
exit 0
}
function compressor()
{
case $1 in
*.tar)
tar -cvf $1 $2
;;
*.tar.gz)
tar -czvf $1 $2
;;
*.tar.bz2)
tar -c $2 | bzip2 > $1
;;
*.bz2)
bzip2 $2
mv "$2".bz2 $1
;;
*.tgz)
tar -czvf $1 $2
;;
*.gz)
gzip -9 $2
mv "$2".gz $1
;;
*.zip)
zip $1 $2
;;
*.7z)
7za a $1 $2
;;
*)
echo "Extent not found"
;;
esac
echo ""
echo "Done"
exit 0
}
if [ -z "$1" ] || [ -n "$3" ]
then
echo "Wrong arguments"
exit 0
else
if [ -n "$2" ]
then
echo "Compressor"
echo "----------"
echo ""
compressor $1 $2
else
echo "Descompressor"
echo "----------"
echo ""
descompressor $1
fi
fi