Ta
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
| #!/usr/bin/env ruby
# encoding: utf-8
def tar(file, ext)
case ext
when /tar.bz2/
"tar jcvf #{file} [DIR]\ntar jxvf #{file}\n"
when /tar.tgz/
"tar zcvf #{file} [DIR]\ntar zxvf #{file}\n"
when /tar.bz/
"tar jxvf #{file}"
when /tar.gz/
"tar zcvf #{file} [DIR]\ntar zxvf #{file}\n"
when /tar.xz/
"tar Jcvf #{file} [DIR]\ntar Jxvf #{file}\n"
when /tar.Z/
"tar Zcvf #{file} [DIR]\ntar Zxvf #{file}\n"
when /tgz/
"tar zcvf #{file} [DIR]\ntar zxvf #{file}\n"
when /tar/
"tar cvf #{file} [DIR]\ntar xvf #{file}\n"
when /zip/
"zip #{file} [DIR]\nunzip #{file}\n"
when /bz2/
"bzip2 -z #{file}\nbzip2 -d #{file}\nbunzip2 #{file}"
when /rar/
"rar a #{file} [DIR]\nrar e #{file}\nrar x #{file} [DIR]\n"
when /lha/
"lha -a #{file} [DIR]\nlha -e #{file}\n"
when /bz/
"bzip2 -d #{file}\nbunzip2 #{file}"
when /xz/
"xz -z #{file}\nxz -d #{file}\n"
when /7z/
"7z a #{file} [DIR]\n7z a #{file}.7z [DIR] -p[PASSWORD]\n7z x #{file}\n"
when /gz/
"gzip #{file}\ngunzip #{file}\ngzip -d #{file}\n"
when /Z/
"uncompress #{file}"
else
ext = "nil" if ext == ""
"error\n#{file}\n#{ext}\n"
end
end
file = ARGV[0]
if not file
puts "ta.rb filename"
exit
end
ext = File.basename(file).scan(/\.(.*)/).join
puts tar(file, ext)
|