Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to get the md5 sum of a file on AIX, but the md5sum program prints the sum followed by the name of the file.

How can I get the sum without the file name.

share|improve this question

3 Answers 3

up vote 3 down vote accepted
md5sum < filename

This will give you an empty filename.

share|improve this answer
2  
That outputs a - to represent stdin. –  Dennis Williamson Nov 5 '10 at 15:53
    
This is what i use. Don't need cat though, just redirect md5sum < filename –  Rich Homolka Nov 5 '10 at 16:53
    
Good point @Rich, I do like that better –  heavyd Nov 5 '10 at 18:58
md5sum filename | awk '{print $1}'

That would be one way.

share|improve this answer
    
That is what I was thinking, just was not sure how he was getting the md5 in the first place. –  Chris Nov 5 '10 at 14:03
    
@Chris I figured this was the way as he mentioned the md5sum program. –  Oliver Salzburg Nov 5 '10 at 14:05

Also:

md5sum filename | cut -c -32

Which has the benefit of having no quotes or characters needing to be escaped, in case you need to embed that command someplace which might have multiple string interpreters acting on it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.