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.

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
2  
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
add comment

3 Answers

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
add comment

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

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

Something like

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

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

share|improve this answer
add comment

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.