|
From: | Pádraig Brady |
Subject: | Re: Enhancement Request for sha256sum - output only the SHA-256 hash alone |
Date: | Fri, 17 Jul 2020 22:33:47 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.0 |
On 17/07/2020 15:21, jens.archlinux jens wrote:
Hello, propose to add a new option for sha256sum to output only the SHA-256 hash alone, without a trailing file name and without a trailing newline. (This would make sense for one input file only). It would make shell scripts that use sha256sum much simpler. Currently it is necessary to split the output of sha256sum to obtain the hash, which usually requires an additional command / Unix process.
This is one of those trade-offs. I'd be 60:40 against adding such an option, because it's so easy to implement with cut(1): sum=$(sha256sum file | cut -d ' ' -f 1) Yes that's an extra process, but you can easily enough avoid that on any POSIX shell using: sum=$(sha256sum file) && sum=${sum%% *} cheers, Pádraig
[Prev in Thread] | Current Thread | [Next in Thread] |