Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想用 ruby 压缩文件。例如我有文件:
base_1.txt base_2.txt base_3.txt
我希望这些文件压缩到base.bz
base.bz
我怎样才能在红宝石中做到这一点?
你看过这个库吗:
https://github.com/brianmario/bzip2-ruby
我不熟悉执行 bz2 操作的 ruby 标准库函数。有一些像上面描述的来自第 3 方的库。
Ruby 还有助于使用操作系统 shell。假设 Linux:您可以调用系统调用:
系统(“bzip2 base_1.txt”)
或等价物:
bzip2 base_1.txt
%x[ bzip2 base_1.txt ]