Register now and start sharing your code snippets.
-->
How to unzip, gunzip, untar files with Ruby
Ruby posted 3 months ago by christian
This is a very advanced and resource efficient algorithm for expanding compressed content with Ruby:
1 def gunzip(filename) 2 command = "gunzip --force #{filename}" 3 success = system(command) 4 5 success && $?.exitstatus == 0 6 end
To customize, change gunzip to whatever command you like.
For example, to avoid 100% CPU utilization during uncompression, set the niceness value of the command with nice -n 5 <command>:
1 command = "nice -n 5 gunzip --force #{filename}"
There’s also ionice…