Current Path : /compat/linux/proc/68247/root/compat/linux/proc/68247/root/compat/linux/usr/share/doc/bash-3.2/scripts.v2/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //compat/linux/proc/68247/root/compat/linux/proc/68247/root/compat/linux/usr/share/doc/bash-3.2/scripts.v2/untar |
#! /bin/bash # # original from: # @(#) untar.ksh 1.0 93/11/10 # 92/10/08 john h. dubois iii (john@armory.com) # 92/10/31 make it actually work if archive isn't in current dir! # 93/11/10 Added pack and gzip archive support # # conversion to bash v2 syntax done by Chet Ramey phelp() { echo \ "$name: extract tar archives into directories, uncompressing if neccessary. Usage: $name archive[.tar[.[Z|gz]]] .. If an archive name given does not end in .tar, .tar.Z, or .tar.gz, it is searched for first with .tar added, then .tar.Z, and then .tar.gz added. The real filename must end in either .tar, .tar.Z, or .tar.gz. A directory with the name of the archive is created in the current directory (not necessarily the directory that the archive is in) if it does not exist, and the the contents of the archive are extracted into it. Absolute pathnames in tarfiles are suppressed." } if [ $# -eq 0 ]; then phelp exit 1 fi name=${0##/} OWD=$PWD for file; do cd $OWD case "$file" in *.tar.Z) ArchiveName=${file%%.tar.Z} zcat=zcat;; *.tar.z) ArchiveName=${file%%.tar.z} zcat=pcat;; *.tar.gz) ArchiveName=${file%%.tar.gz} zcat=gzcat;; *) ArchiveName=$file for ext in "" .Z .z .gz; do if [ -f "$file.tar$ext" ]; then file="$file.tar$ext" break fi done if [ ! -f "$file" ]; then echo "$file: cannot find archive." 1>&2 continue fi ;; esac if [ ! -r "$file" ]; then echo "$file: cannot read." >&2 continue fi DirName=${ArchiveName##*/} [ -d "$DirName" ] || { mkdir "$DirName" || { echo "$DirName: could not make archive directory." 1>&2 continue } } cd $DirName || { echo "$name: cannot cd to $DirName" 1>&2 continue } case "$file" in /*) ;; *) file=$OWD/$file ;; esac echo "Extracting archive $file into directory $DirName..." case "$file" in *.tar.Z|*.tar.z|*.tar.gz) $zcat $file | tar xvf -;; *.tar) tar xvf $file;; esac echo "Done extracting archive $file into directory $DirName." done