... | ... |
@@ -37,3 +37,24 @@ function take() { |
37 | 37 |
mkdir -p $1 |
38 | 38 |
cd $1 |
39 | 39 |
} |
40 |
+ |
|
41 |
+function extract() { |
|
42 |
+ if [[ -f $1 ]]; then |
|
43 |
+ case $1 in |
|
44 |
+ *.tar.bz2) tar xvjf $1;; |
|
45 |
+ *.tar.gz) tar xvzf $1;; |
|
46 |
+ *.bz2) bunzip $1;; |
|
47 |
+ *.rar) unrar $1;; |
|
48 |
+ *.gz) gunzip $1;; |
|
49 |
+ *.tar) tar xvf $1;; |
|
50 |
+ *.tbz2) tar xvjf $1;; |
|
51 |
+ *.tgz) tar xvzf $1;; |
|
52 |
+ *.zip) unzip $1;; |
|
53 |
+ *.Z) uncompress $1;; |
|
54 |
+ *.7z) 7z x $1;; |
|
55 |
+ *) echo "'$1' cannot be extracted via >extract<";; |
|
56 |
+ esac |
|
57 |
+ else |
|
58 |
+ echo "'$1' is not a valid file" |
|
59 |
+ fi |
|
60 |
+} |