X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=ex;h=cd9bd78ec0b367546d7d5e32dc6b59f9f210ce75;hb=02239b8021771f96788497c79161fb078898c576;hp=f944f6556f50004f8eab4e005405a8f043c5c0d9;hpb=d73e2d49c5a9275625efb2b124ad56145113e245;p=small-misc-bash diff --git a/ex b/ex index f944f65..cd9bd78 100755 --- a/ex +++ b/ex @@ -15,30 +15,30 @@ ex() { local help="Usage: ex [--help] FILE... -Extract each FILE according to its extension. -7z bz2 deb gz iso dsc rar rpm tar xz zip & some combinations. +Extract many types of files + +Based on their extensions, +7z [tar.]bz2 deb [tar.]gz iso dsc rar rpm sfs tar xpi [tar.]xz zip Z. See source for exact file extensions. -Note: apt-get install dtrx will do the same for -most of these types, plus some more, I'm going -to try it out sometime." +Note: dtrx (package & command) extracts most of these plus some others." + if [[ $1 == --help ]]; then echo "$help" fi local x super for x in "$@"; do case "$x" in + # tars first, so they are higher pri than non-tar extensions + *.tar ) tar xf "$x" ;; *.tar.bz2 | *.tbz2 ) tar xjf "$x" ;; *.tar.gz | *.tgz ) tar xzf "$x" ;; - *.bz2 ) bunzip2 "$x" ;; - *.gz ) gunzip "$x" ;; - *.tar ) tar xf "$x" ;; - *.zip ) unzip "$x" ;; - *.Z ) uncompress "$x" ;; - *.7z ) 7za x "$x" ;; - *.deb ) ar x "$x" ;; - *.rpm ) rpm2cpio "$x" | cpio --extract --make-directories ;; *.tar.xz ) tar Jxf "$x" ;; *.xz) xz -d "$x" ;; + *.7z ) 7za x "$x" ;; + *.bz2 ) bunzip2 "$x" ;; + *.deb ) ar x "$x" ;; + *.dsc) dpkg-source -x "$x" ;; + *.gz ) gunzip "$x" ;; *.iso ) local super if [[ $EUID != 0 ]]; then @@ -52,10 +52,14 @@ to try it out sometime." cp -a "$temp_dir"/* "$dir" $super umount "$temp_dir" ;; + *.jar) jar xf "$x" ;; *.r[0-9][0-9]|*.rar ) unrar x "$x" ;; - *.dsc) dpkg-source -x "$x" ;; - *.sfs) $user unsquashfs "$x" ;; - *) echo "I don't kno how to extract $x";; + *.rpm ) rpm2cpio "$x" | cpio --extract --make-directories ;; + *.sfs) $super unsquashfs "$x" ;; + *.Z ) uncompress "$x" ;; + *.zip|*.xpi ) unzip "$x" ;; + + *) echo "I don't know how to extract $x";; esac done }