2 # Copyright (C) 2014 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 local help="Usage: ex [--help] FILE...
18 Extract each FILE according to its extension.
19 7z bz2 deb gz iso rar rpm tar xz zip & variations.
20 See source for exact file extensions."
21 if [[ $1 == --help ]]; then
27 *.
tar.bz2 |
*.tbz2
) tar xjf
"$x" ;;
28 *.
tar.gz |
*.tgz
) tar xzf
"$x" ;;
29 *.bz2
) bunzip2
"$x" ;;
31 *.
tar ) tar xf
"$x" ;;
33 *.Z
) uncompress "$x" ;;
36 *.rpm
) rpm2cpio
"$x" |
cpio --extract --make-directories ;;
37 *.
tar.xz
) tar Jxf
"$x" ;;
41 if [[ $EUID != 0 ]]; then
44 local temp_dir
=$
(mktemp
-d)
46 $super mount
-o loop
"$x" "$temp_dir"
47 local dir
="${x%%.iso}"
49 cp -a "$temp_dir"/* "$dir"
50 $super umount
"$temp_dir"
52 *.r
[0-9][0-9]|
*.rar
) unrar x
"$x" ;;
53 *.dsc
) dpkg-source
-x "$x" ;;
54 *) echo "I don't kno how to extract $x";;