I need to create an md5 hash of every directory and file inside of one main directory. The only thing that is keeping me from success is figuring out a way around files with a space in the path.
I am using find for the recursive listing (I have read that find is the best way of doing this):
c5-26-1# find /root/newdir
/root/newdir
/root/newdir/1
/root/newdir/2
/root/newdir/3
/root/newdir/4
/root/newdir/5
/root/newdir/newdir2
/root/newdir/newdir2/1
/root/newdir/newdir2/2
/root/newdir/new
/root/newdir/dir
/root/newdir/new dir
When I try this with md5 I get two different outcomes, neither of which work:
c5-26-1# md5 $(find /root/newdir) # same outcome using for loop
MD5 (/root/newdir) = bc79a580f6c932937f6fcd454747db72
MD5 (/root/newdir/1) = 94ca98295946310ce88e185ea57486d5
MD5 (/root/newdir/2) = 8432051f64459be5a5e73dc2abd91795
MD5 (/root/newdir/3) = d41d8cd98f00b204e9800998ecf8427e
MD5 (/root/newdir/4) = d41d8cd98f00b204e9800998ecf8427e
MD5 (/root/newdir/5) = d41d8cd98f00b204e9800998ecf8427e
MD5 (/root/newdir/newdir2) = 722165901468b9596dbdddfe118759fb
MD5 (/root/newdir/newdir2/1) = d41d8cd98f00b204e9800998ecf8427e
MD5 (/root/newdir/newdir2/2) = d41d8cd98f00b204e9800998ecf8427e
MD5 (/root/newdir/new) = 89d042c5f9d6ba485a654b543685ea86
MD5 (/root/newdir/dir) = 148538718feba14839f5d1072854c5f4
MD5 (/root/newdir/new) = 89d042c5f9d6ba485a654b543685ea86
MD5 (dir) = 148538718feba14839f5d1072854c5f4
or
c5-26-1# find -X /root/newdir | xargs md5
find: /root/newdir/new dir: illegal path
MD5 (/root/newdir) = bc79a580f6c932937f6fcd454747db72
MD5 (/root/newdir/1) = 94ca98295946310ce88e185ea57486d5
MD5 (/root/newdir/2) = 8432051f64459be5a5e73dc2abd91795
MD5 (/root/newdir/3) = d41d8cd98f00b204e9800998ecf8427e
MD5 (/root/newdir/4) = d41d8cd98f00b204e9800998ecf8427e
MD5 (/root/newdir/5) = d41d8cd98f00b204e9800998ecf8427e
MD5 (/root/newdir/newdir2) = 722165901468b9596dbdddfe118759fb
MD5 (/root/newdir/newdir2/1) = d41d8cd98f00b204e9800998ecf8427e
MD5 (/root/newdir/newdir2/2) = d41d8cd98f00b204e9800998ecf8427e
MD5 (/root/newdir/new) = 89d042c5f9d6ba485a654b543685ea86
MD5 (/root/newdir/dir) = 148538718feba14839f5d1072854c5f4
How do I account for directories with spaces?