Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 4 down vote accepted
md5sum < filename

This will give you an empty filename.

share|improve this answer
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
This will remove the "-" from the md5sum < filename – Diego Andrés Díaz Espinoza Feb 17 '15 at 19:11


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

Another way is to do :

md5sum filename |cut -f 1 -d " "

Cut will split line to each space and return only first field.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .