Binary files comparision

M

Marcin Tyman

Hallo guys,
I've got 2 folders with content which I need to binary compare (file by
file). Is in ruby any library to help me with this?
Any other ideas?

Thanks in advance
 
R

ruud grosmann

something like:

cksum1 = `cksum #{file1}`
cksum1.sub!( /(\d+)\s.*/, '\1')
cksum2 = `cksum #{file2}`
cksum2.sub!( /(\d+)\s.*/, '\1')

cksum1 == chsum2

Or is this not what you're after?

regards, Ruud
 
R

Robert Klemme

2008/9/3 ruud grosmann said:
something like:

cksum1 = `cksum #{file1}`
cksum1.sub!( /(\d+)\s.*/, '\1')
cksum2 = `cksum #{file2}`
cksum2.sub!( /(\d+)\s.*/, '\1')

cksum1 == chsum2

Or is this not what you're after?

In that case why not directly use cmp? I thought the OP wanted a Ruby version.

For small files this could be as easy as

File.read(f1) == File.read(f2)

Marcin, what kind of comparison do you need? Especially what output
do you expect?

Kind regards

robert
 
M

Marcin Tyman

ruud said:
something like:

cksum1 = `cksum #{file1}`
cksum1.sub!( /(\d+)\s.*/, '\1')
cksum2 = `cksum #{file2}`
cksum2.sub!( /(\d+)\s.*/, '\1')

cksum1 == chsum2

Or is this not what you're after?

regards, Ruud

Not exactly. I run script on Windows.
 
T

Tim Hunter

Marcin said:
Hallo guys,
I've got 2 folders with content which I need to binary compare (file by
file). Is in ruby any library to help me with this?
Any other ideas?

Thanks in advance

The FileUtils library includes compare_file(a, b).

ri FileUtils
 

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,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top