Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kzinthant-kas authored Sep 22, 2021
1 parent fd31d7d commit 68a333c
Show file tree
Hide file tree
Showing 2 changed files with 399 additions and 0 deletions.
199 changes: 199 additions & 0 deletions extract
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
#!/bin/bash

if [ $# -lt 1 ]; then
echo "Usage: $(basename $0) FILES"
exit 1
fi

extract() {
arg="$1"
cd "$(dirname "$arg")" || exit
case "$arg" in
*.tar.bz2)
tar xjf "$arg" --one-top-level
local code=$?
;;
*.tar.gz)
tar xzf "$arg" --one-top-level
local code=$?
;;
*.bz2)
bunzip2 "$arg"
local code=$?
;;
*.gz)
gunzip "$arg"
local code=$?
;;
*.tar)
tar xf "$arg" --one-top-level
local code=$?
;;
*.tbz2)
(tar xjf "$arg" --one-top-level)
local code=$?
;;
*.tgz)
tar xzf "$arg" --one-top-level
local code=$?
;;
*.tar.xz)
a_dir=$(expr "$arg" : '\(.*\).tar.xz')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.zip)
a_dir=$(expr "$arg" : '\(.*\).zip')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.7z)
a_dir=$(expr "$arg" : '\(.*\).7z')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.Z)
uncompress "$arg"
local code=$?
;;
*.rar)
a_dir=$(expr "$arg" : '\(.*\).rar')
mkdir "$a_dir"
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.iso)
a_dir=$(expr "$arg" : '\(.*\).iso')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.wim)
a_dir=$(expr "$arg" : '\(.*\).wim')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.cab)
a_dir=$(expr "$arg" : '\(.*\).cab')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.apm)
a_dir=$(expr "$arg" : '\(.*\).apm')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.arj)
a_dir=$(expr "$arg" : '\(.*\).arj')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.chm)
a_dir=$(expr "$arg" : '\(.*\).chm')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.cpio)
a_dir=$(expr "$arg" : '\(.*\).cpio')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.cramfs)
a_dir=$(expr "$arg" : '\(.*\).cramfs')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.deb)
a_dir=$(expr "$arg" : '\(.*\).deb')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.dmg)
a_dir=$(expr "$arg" : '\(.*\).dmg')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.fat)
a_dir=$(expr "$arg" : '\(.*\).fat')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.hfs)
a_dir=$(expr "$arg" : '\(.*\).hfs')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.lzh)
a_dir=$(expr "$arg" : '\(.*\).lzh')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.lzma)
a_dir=$(expr "$arg" : '\(.*\).lzma')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.lzma2)
a_dir=$(expr "$arg" : '\(.*\).lzma2')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.mbr)
a_dir=$(expr "$arg" : '\(.*\).mbr')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.msi)
a_dir=$(expr "$arg" : '\(.*\).msi')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.mslz)
a_dir=$(expr "$arg" : '\(.*\).mslz')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.nsis)
a_dir=$(expr "$arg" : '\(.*\).nsis')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.ntfs)
a_dir=$(expr "$arg" : '\(.*\).ntfs')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.rpm)
a_dir=$(expr "$arg" : '\(.*\).rpm')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.squashfs)
a_dir=$(expr "$arg" : '\(.*\).squashfs')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.udf)
a_dir=$(expr "$arg" : '\(.*\).udf')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.vhd)
a_dir=$(expr "$arg" : '\(.*\).vhd')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*.xar)
a_dir=$(expr "$arg" : '\(.*\).xar')
7z x "$arg" -o"$a_dir"
local code=$?
;;
*)
echo "'$arg' cannot be extracted via extract()" 1>&2
exit 1
;;
esac
cd - || exit $?
exit $code
}

extract "$1"
Loading

0 comments on commit 68a333c

Please sign in to comment.