Skip to content

Instantly share code, notes, and snippets.

@fadelakin
Created October 27, 2013 16:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fadelakin/7184429 to your computer and use it in GitHub Desktop.
Save fadelakin/7184429 to your computer and use it in GitHub Desktop.
Ruby script to copy one file to another
# ruby script to copy one file to another.
from_file, to_file = ARGV
script = $0
puts "Copying from #{from_file} to #{to_file}"
# we could do these two on one line too, how?
input = File.open(from_file)
indata = input.read()
puts "The input file is #{indata.length} bytes long"
puts "Does the output file exist? #{File.exists? to_file}"
puts "Ready, hit RETURN to continue, CTRL-C to abort."
STDIN.gets
output = File.open(to_file, 'w')
output.write(indata)
puts "Alright, all done."
output.close()
input.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment