trailing slash issue in Find.find

J

Jeff Mitchell

require "find"
Find.find("/usr/bin/") { |file| puts file }

[...]
/usr/bin//rmdir
/usr/bin//rm
/usr/bin//mv
/usr/bin//mknod
/usr/bin//mkfifo
/usr/bin//mkdir
/usr/bin//ls
/usr/bin//ln
/usr/bin//install
/usr/bin//du
/usr/bin//dircolors
/usr/bin//dir
/usr/bin//df
/usr/bin//dd
/usr/bin//cp
[...]

I ran into this while doing string compares between filenames obtained
from File.find and filenames obtained elsewhere. Needless to say they
didn't compare very well :)

FWIW, GNU's find, BSD's find, and perl's find all produce the same output
for "/usr/bin" and "/usr/bin/".

-Jeff
 

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

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top