Using Raku (formerly known as Perl_6)
raku -ne '.words[*-2..*].put;'
Sample Input:
[ 3] 1.0- 2.0 sec 1.00 MBytes 8.39 Mbits/sec
[ 3] 2.0- 3.0 sec 768 KBytes 6.29 Mbits/sec
[ 3] 3.0- 4.0 sec 512 KBytes 4.19 Mbits/sec
[ 3] 4.0- 5.0 sec 256 KBytes 2.10 Mbits/sec
Sample Output:
8.39 Mbits/sec
6.29 Mbits/sec
4.19 Mbits/sec
2.10 Mbits/sec
You might want to try Raku, a member of the Perl-family of programming languages. Above, the words
routine breaks on whitespace. Columns can be selected with square brackets: since Raku (and Perl) are zero-indexed, the second-to-last column is *-2
and the last column is *-1
. Here, either words[*-2..*-1]
or words[*-2..*]
works, the latter indicating 'give me the second-to-last column up to *
whatever'.
Oh, the OP only wants the second-to-last column? Titled by the last column?
~$ raku -ne '.words[*-1].put if ++$ == 1; .words[*-2].put;' file
Mbits/sec
8.39
6.29
4.19
2.10
https://docs.raku.org/routine/words
https://raku.org
Mbits/sec
, is that what you want or the 2 last columns? – terdon Jan 18 '14 at 14:43wg show all latest-handshakes
which looks like multiple whitespace for separator (I don't really know) and it turns out that the default separator (whatever that is) worked fine! So<cmd> | cut -f 3
worked nicely. – Karl Pokus Mar 24 '21 at 12:24