Re: ZFS no longer mounted in alphanumerical order

From: Jan Martin Mikkelsen <janm_at_transactionware.com>
Date: Tue, 12 Mar 2019 13:52:37 +0100
> On 12 Mar 2019, at 12:14, Trond Endrestøl <Trond.Endrestol_at_fagskolen.gjovik.no> wrote:
>> An alternative sort approach, which handles df arguments which change the number of columns, and only invokes df once:
>> 
>> ${DF} "$_at_" | awk '/^Filesystem/ { print; sort = "sort -k " NF } ! /^Filesystem/ { print | sort }’
> 
> Well, yes and no, mostly no.
> 
> Why are we feeding each line from df(1) separately to sort(1)?
> It defeats the entire purpose. No sorting takes place.
> 
> We might be better off accumulating the majority of the lines and 
> sorting them in an END block.


That’s not how awk works. It maintains a pipe and feeds each line to the same sort process.

There is another bug there, of course. The field number should be (NF - 1) because of the space in the “Mounted on” header on the last column. That’s what I get for just typing code into an email.

Regards,

Jan M.
Received on Tue Mar 12 2019 - 11:52:53 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:20 UTC