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

running sha256sum folder/file` returns

711ad4b9939e0e20e591d753103717f40e794babc4129a0670fd342309bec5af *folder/file

I want to output the sum with just the filename next to it so that it looks like:

711ad4b9939e0e20e591d753103717f40e794babc4129a0670fd342309bec5af file

How do I go about changing the output?

share|improve this question
sed is your friend - you'll have to get somebody else to tell you how to use it ;) – new123456 Apr 20 '11 at 21:33
up vote 3 down vote accepted

You could try

sha256sum /path/to/file | head -c 64

This is for taking only the hash of 64 characters. As there were mentioned before, you should read the man of sed for more advanced manipulation.

But to have the output that you want, I mean without folders, a simple way is running the command from the folder where the file is located ;)

In your case:

cd folder/ ; sha256sum file
share|improve this answer

Don't run sha256sum folder/file then. Change to the directory first:

( cd folder && sha256sum file )
share|improve this answer

Something like

sha256sum folder/file | sed 's, .*/, ,'

should do the job. I didn't test it though.

share|improve this answer

You must log in to answer this question.

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