2019-08-23 10:41:01 +0100, coreut...@fastmail.com:
[...]
> $ echo 'hello world' | md5sum
> 6f5902ac237024bdd0c176cb93063dc4  -
> 
> What's use is the '-'?
> 
> Obviously it indicates the file content it taken from the
> standard input, but is that of any actual use?
[...]

It is used by md5sum -c.

$ echo test | md5sum | tee s
d8e8fca2dc0f896fd7cb4cb0031ba249  -
$ echo test | md5sum -c s
-: OK

Having said that, it's far less common a usage pattern than doing:

sum=$(md5sum < file)

And I agree it is annoying having to strip that "-".

It's the same kind of "annoying" as the

length=$(wc -c < file)

That has blanks around the number in many wc implementations and
which GNU wc fixed.

FWIW, the ast-open implementation of "wc" doesn't output that
"-" and doesn't treat "-" as meaning stdin. If you want to
"md5sum -c" stdin there, you need to use "/dev/stdin" instead of
"-".

I'd rather GNU md5sum only output "-" when "-" is passed on the
command line.

Maybe --quiet could be used to skip outputting file names.

-- 
Stephane


Reply via email to