November 2008
Intermediate to advanced
208 pages
4h 32m
English
A cool use of Ruby scripting is to split a large file into several smaller, symmetric files. I wrote this script for a friend who was having trouble sending files into and out of his corporate network since the network administrators wouldn't allow files over a certain size to be transferred—presumably for bandwidth reasons. This script worked like a charm.
if ARGV.size != 2 puts "Usage: ruby fileSplit.rb <filename.ext> <size_of_pieces_in_bytes>" puts "Example: ruby fileSplit.rb myfile.txt 10" exit end filename = ARGV[0] size_of_split = ARGV[1] if File.exists?(filename) file = File.open(filename, ...
Read now
Unlock full access