⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 untar

📁 UNIX下SH的实现源码
💻
字号:
#! /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 Rameyphelp(){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 issearched 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.  Adirectory with the name of the archive is created in the current directory(not necessarily the directory that the archive is in) if it does notexist, and the the contents of the archive are extracted into it. Absolute pathnames in tarfiles are suppressed."}if [ $# -eq 0 ]; then    phelp    exit 1finame=${0##/}OWD=$PWDfor 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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -