Question

I have a CD whose contents I need to hash using sha256sum and I need to store its output to a single text file. How can I do this in a single command? I tried "echo sha256sum * >> shasum.txt" but what it did was it only appended the text sha256sum to all the files in the root folder and not what I really intended for it to do. Help please?

Edit: How can I do this command such that it affects ALL the files in the subfolders?

Was it helpful?

Solution

That was close. I think you want to do:

sha256sum * > shasum.txt

Edit: if you got subfolders, then something like that should work:

find myFolder -type f | xargs sha256sum >  shasum.txt

or in the folder:

find . -type f | xargs sha256sum >  shasum.txt

if you want only some files you can filter with -name:

find . -type f -name "*.wav" | xargs sha256sum >  shasum.txt

if you have filenames with newlines or strange things, you can use -print0:

find . -type f -print0 | xargs -0 sha256sum >  shasum.txt
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top