ex17 extra credit #3
This commit is contained in:
parent
f23ea03671
commit
a295260e52
28
ex17-ec.rb
28
ex17-ec.rb
@ -1,23 +1,5 @@
|
|||||||
|
File.open(ARGV.first) do |infile|
|
||||||
from_file, to_file = ARGV
|
File.open(ARGV[1], 'w') do |outfile|
|
||||||
script = $0
|
outfile.write(infile.read)
|
||||||
|
end
|
||||||
puts "Copying from #{from_file} to #{to_file}"
|
end
|
||||||
|
|
||||||
# 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()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user