0

With bash, how to get 1 Line from xxhsum --version ?

Ubuntu 20.04.4 LTS (Focal Fossa)

Why unexpected bash results with
pipe | head and
pipe | awk ?

Examples below work as expected:

md5sum --version

md5sum (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Ulrich Drepper, Scott Miller, and David Madore.

md5sum --version | head -n1
md5sum (GNU coreutils) 8.30

md5sum --version | head -n 1
md5sum (GNU coreutils) 8.30

md5sum --version | awk 'NR==1'
md5sum (GNU coreutils) 8.30

But there is a faster hasher
xxhsum
i am testing it, also called
xxhash

xxhsum --version
xxhsum 0.8.1 by Yann Collet
compiled as 64-bit x86_64 autoVec little endian with GCC 9.3.0

All the above is as expected.
But unexpected results with:

xxhsum --version | head -n1
xxhsum 0.8.1 by Yann Collet
compiled as 64-bit x86_64 autoVec little endian with GCC 9.3.0

xxhsum --version | head -n 1
xxhsum 0.8.1 by Yann Collet
compiled as 64-bit x86_64 autoVec little endian with GCC 9.3.0

xxhsum --version | awk 'NR==1'
xxhsum 0.8.1 by Yann Collet
compiled as 64-bit x86_64 autoVec little endian with GCC 9.3.0

unexpected results because
2 Lines are printed to screen, not 1 Line.

Regarding xxhsum ...
How come 2 Lines are printed to screen?

How to get 1 Line printed from
xxhsum --version ?

--

joseph22
  • 509

0 Answers0