Pádraig Brady wrote: > jens wrote: > > 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):
I feel that way too. It's just so easy to do in the shell. > 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%% *} I'll suggest always using stdin instead ("sha256sum < file") as that avoids any possible quoting of things to get in the way. In the case where the filename contains special characters. And then just to show yet a different way to keep from using external processes. set -- $(sha256sum < file) && sum=$1 But this does assume one is no longer using the positional arguments at that point. Bob