-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathac-archiving
More file actions
executable file
·55 lines (51 loc) · 1.16 KB
/
ac-archiving
File metadata and controls
executable file
·55 lines (51 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/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 -zcvf "$o" "$@";;
*.tar.bz2|*.tbz2)
tar -jcvf "$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