ruby - bzip files
I want to compress the files in ruby. for example I have file:
base_1.txt
base_2.txt
base_3.txt
I want these files compressed to base.bz
How can I do it in r开发者_StackOverflow中文版uby?
Have you looked at this library:
https://github.com/brianmario/bzip2-ruby
I am not familiar with a standard library function for ruby that performs bz2 operations. There are a few libraries like the one described above from 3rd party.
Ruby also facilitates using the operating systems shell. Assuming Linux: You could call the system call:
system("bzip2 base_1.txt")
or the equivalents:
bzip2 base_1.txt
%x[ bzip2 base_1.txt ]
精彩评论