HT compare files in Ruby?...

K

Kurt Euler

All-

Can anyone advise:

1) If there is a Ruby (boolean?) method that will compare the contents of
two files and return indication as to whether or not their contents are
identical?

2) Beyond this, does anyone know of a Ruby script available that will prompt
the user for two directories, then proceed to check for files (recursively
into subdirectories) in the two directories are different, and write the
names of non-identical pairs to the display/file. Sounds simple enough to
write (esp using any tip provided in #1 above), but just thought if someone
else has already done the (eg, directory prompting UI) legwork).

Many thanks.

Kurt Euler
 
J

Joel VanderWerf

Kurt said:
1) If there is a Ruby (boolean?) method that will compare the contents of
two files and return indication as to whether or not their contents are
identical?

require 'ftools'
File.cmp('f1', 'f2')
 
J

Johan Holmberg

require 'ftools'
File.cmp('f1', 'f2')

Or maybe

require 'fileutils'
FileUtils.cmp('f1', 'f2')


For some reason Ruby always seem to have at least
two ways of doing things ;-)

/Johan Holmberg
 
G

gabriele renzi

All-

Can anyone advise:

1) If there is a Ruby (boolean?) method that will compare the contents of
two files and return indication as to whether or not their contents are
identical?

require 'fileutils'
FileUtils.cmp('file','other')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top