I have a command that outputs many lines and I would like to awk '{print $(NF)}'
last line to extract 681096.53k
.
$ openssl speed -multi $(nproc) sha256
…
OpenSSL 1.1.1k 25 Mar 2021
built on: Tue Aug 24 08:28:12 2021 UTC
options:bn(64,64) rc4(char) des(int) aes(partial) blowfish(ptr)
compiler: gcc -fPIC -pthread -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -ffile-prefix-map=/build/openssl-no81cX/openssl-1.1.1k=. -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DVPAES_ASM -DECP_NISTZ256_ASM -DPOLY1305_ASM -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2
sha256 128441.33k 293748.99k 516125.27k 635319.30k 681096.53k 685266.26k
Would like to achieve this as a one-liner… is that possible?
CodePudding user response:
Use END
to execute the print after all input has been read, at which point NF
and $0
(which $NF
will refer to) will still retain the values they took from the last line.
openssl speed -multi $(nproc) sha256 | awk 'END {print $NF}'