代码: 全选
tlcr: 0 庚寅年六月初七日 13:42:17 ~
>> ds ac-归档.bash
#!/bin/bash
# vim :set ft=bash
scriptName=ac-归档.bash
pkgver=0.1
. scriptFunctions
help()
{
echog """
Usage: %s [options] [files to ca]
Options:
--help Print help info
--version Print version info
-o file, --output=file Set output file
""" "$0"
}
o=/dev/stdout
while [[ $# > 0 ]] ; do
case "$1" in
--help)help; exit;;
--version)version; exit;;
-o)shift ; o="$1" ;;
--output=*)o="${1#--output=}";;
--)
shift
break;;
-*)
dieg "$Ec_OptionError" "Error: Unknown option \`%s'" "$1" >&2;;
*)break;;
esac
shift
done
case "$o" in
*.tar.lzma|*.tlz)
tar --lzma -cf "$o" "$@";;
*.tar.gz|*.tgz)
tar -zcf "$o" "$@";;
*.tar.bz2|*.tbz2)
tar -jcf "$o" "$@";;
*.tar.lzip|*.tar.lz|*.tlzip)
tar -c "$@" | lzip -9c > "$o";;
*.tar)tar -cf "$o" "$@";;
*.gz)gzip -9c "$1" > "$o";;
*.bz2)bzip2 -9c "$1" > "$o";;
*.lzma)lzma -9c "$1" > "$o";;
*.lzip|*.lz)lzip -9c "$1" > "$o";;
/dev/stdout)
tar -c "$@";;
*)
warng "无法根据文件名判断文件类型。使用tar。" >&2
tar -cf "$o" "$@";;
esac
tlcr: 0 庚寅年六月初七日 13:42:52 ~
>> ds ae-解压.bash
#!/bin/bash
# vim: ft=bash
scriptName=ae-解压.bash
pkgver=0.1
. scriptFunctions
help()
{
echog """
Usage: %s [options] [file]
Options:
--help Print this help info
--version Print version info
""" "$0"
}
while [[ $# > 0 ]] ; do
case "$1" in
--help)
help;exit;;
--version)
version;exit;;
--)
shift
break;;
#-C|--change-directory)
# [ "$2" ] && { directory="$2"; shift 1; } || { echog "Error: Option error" >&2 ; echog "Error: Arg for option \`%s'not found." "$1" ; exit 1 ;}
# ;;
-*)
dieg "$Ec_OptionError" "未知选项 \`%s'" "$1" >&2
exit 1;;
*)break;;
esac
shift
done
file="$1"
[ -z "$file" ] && { dieg "$Ec_ProgramError" "没有指定文件" >&2 ; exit 1; }
shift 1
case "$file" in
*.tar)tar -xf "$file";;
*.tar.gz|*.tgz)tar -zxf "$file";;
*.tar.bz2|*.tbz2)tar -jxf "$file";;
*.tar.lzma|*.tlz)tar --lzma -xf "$file";;
*.tar.lzip|*.tar.lz|*.tlzip)lzip -dc "$file" | tar -x;;
*.zip)unzip "$file";;
*.rar)rar x "$file";;
*.gz)zcat "$file";;
*.bz2)bzcat "$file";;
*.lzma)lzcat "$file";;
*.lzip|*.lz)lzip -dc "$file";;
*)
warng "无法根据文件名判断文件类型,尝试tar。" >&2
tar -xf "$file";;
esac
tlcr: 0 庚寅年六月初七日 13:43:37 ~
>>
估计都是回帖不看帖的,
代码: 全选
\e9nd
估计这个脚本用的人不多,不过吾自己就经常用