Re: sha256sum --text generating blank spaces and hyphens?
Hi,
Albretch Mueller wrote:
> > > I am trying to avoid funky characters and sha256sum --text still
> > > generates them!?!
Andy Smith wrote:
> > If you're referring to the space and then the file name ("-" in case
> > of stdin) on the end, you can just select only the first output up
> > to whitespace with e.g. awk:
> Yes, you could but I am trying to find out why this is happening
> instead of truncating the string when a space appears because I don't
> think what would be safe.
One of the blanks and the hyphen-or-minus are announced by the man page:
The default mode is
to print a line with checksum, a character indicating input mode ('*'
for binary, space for text), and name for each FILE.
"FILE" is the minus-sign for standard input. The second blank is there
to indicate the text mode of sha256sum.
Only the first blank is somewhat puzzling. But it's always there.
https://www.gnu.org/software/coreutils/manual/html_node/sha2-utilities#sha2-utilities
points to
https://www.gnu.org/software/coreutils/manual/html_node/md5sum-invocation.html
which says
For each file, ‘md5sum’ outputs by default, the MD5 checksum, a space,
a flag indicating binary or text input mode, and the file name. Binary
mode is indicated with ‘*’, text mode with ‘ ’ (space). Binary mode is
the default on systems where it’s significant, otherwise text mode is
the default. The cksum command always uses binary mode and a ‘ ’
(space) flag.
So the first blank can be relied on and thus the proposal by Andy Smith
to use "awk '{print $1}'" is valid.
Have a nice day :)
Thomas
Reply to: