LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 04-30-2008, 10:22 PM   #1
madivad
Member
 
Registered: Jan 2007
Posts: 70

Rep: Reputation: 15
hash all files in subdirs


What is the best way to do this?

I see solaris (I'm using developer preview 2) has an md5sum command, but it's not very friendly. it is upset up dirnames (simple error) and will not recurse.

I have tried args and am hitting my head against a brick wall, these are my attempts so far:

1) build a list of files with
find /store/data

This will print a list of files to be hashed

2) pass it through xargs to md5sum
find /store/data | xargs md5sum | tee sums

the tee sums on the end is just so that it prints to screen and a log file to be used later, at least that is the intention

The main problem I am having is that there are whitespaces in the filenames, and the -0 (or --null) of xargs is not implemented in solaris, nor is the -print0 of find.

on directories and files without spaces, it works, but parses by space (and hence breaks up) when a filename or dir has a space. Also, because of filename problems, the listing is halted only a few files into the process, yet without "xargs md5sum", the whole list of all files is processed

Any hints or suggestions?
 
Old 05-01-2008, 02:16 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Try this:
Code:
find /store/data -type f -exec xargs md5sum {} + | tee sums
 
Old 05-01-2008, 03:13 AM   #3
madivad
Member
 
Registered: Jan 2007
Posts: 70

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jlliagre View Post
Try this:
Code:
find /store/data -type f -exec xargs md5sum {} + | tee sums
just doesn't work, it seems xargs is now having a problem with "max arglist" being greater than 2048 characters.

Now that can't be referring to the length of filenames, even with burried directories, I can't see a filename length of 2K characters! LOL

Also, I should point out, there are about 22000 files that this needs to process, is that the problem?

This is the error I am receiving:
Code:
dave@solaris:~# find /solaraid/TB2 -type f -exec xargs md5sum {} +
xargs: a single arg was greater than the max arglist size of 2048 characters
xargs: a single arg was greater than the max arglist size of 2048 characters
xargs: a single arg was greater than the max arglist size of 2048 characters
dave@solaris:~#
and considering it's 22000 files, I am only getting this error 3 times. And when passed to the file (as in: | tee sums), the file is empty
 
Old 05-01-2008, 04:12 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
My mistake, a cut and paste error, this is really what I wanted to suggest:
Code:
find /store/data -type f -exec md5sum {} + | tee sums
 
Old 05-01-2008, 06:34 AM   #5
madivad
Member
 
Registered: Jan 2007
Posts: 70

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jlliagre View Post
My mistake, a cut and paste error, this is really what I wanted to suggest:
Code:
find /store/data -type f -exec md5sum {} + | tee sums
No problems, if I had a little better grasp of the ins and outs of unix commands I could have spotted it myself anyway, but then I wouldn't have posted here asking for help ;-P

As always, your help is appreciated immensely.
 
Old 05-01-2008, 07:01 AM   #6
madivad
Member
 
Registered: Jan 2007
Posts: 70

Original Poster
Rep: Reputation: 15
I have just been reading over the find/exec command operation, and with the appended '+'...

Am I reading this correctly?
Quote:
-exec command {} +
This variant of the -exec option runs the specified command on
the selected files, but the command line is built by appending
each selected file name at the end; the total number of invoca-
tions of the command will be much less than the number of
matched files.
The command line is built in much the same way
that xargs builds its command lines. Only one instance of '{}'
is allowed within the command. The command is executed in the
starting directory.
Does this mean that all the file names are concatenated to a command line and passed to the md5sum? That os the way I am reading it, and to make it more interesting, that males a command line of over 2,000,000 characters!

That's pretty impressive!

Ahh, re-reading it on preview...
"the total number of invocations of the command will be much less than the number of matched files."

So, it might call the md5sum application 100 or 1000 times, but not the full 22,000 times (the number of files)? or is it called just once?
 
Old 05-01-2008, 09:37 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
md4sum is called the minimum number of times possible. It could be once only if the list of files fit in a command line.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
need help unpacking hmac-md5 hash into md5 hash lynx5 Programming 3 02-02-2008 04:06 PM
Copy files in subdirs to one dir Rotwang Linux - General 4 12-14-2007 01:30 PM
Using hash value as key for other hash in Perl scuzzman Programming 6 02-14-2006 05:08 PM
recurse through subdirs? Axion Linux - Software 4 02-16-2004 08:12 PM
mounting subdirs dARkHunTEr Linux - General 2 11-04-2003 08:32 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 09:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration