> On 12 Mar 2019, at 12:14, Trond Endrestøl 
> <[email protected]> wrote:
>> An alternative sort approach, which handles df arguments which change the 
>> number of columns, and only invokes df once:
>> 
>> ${DF} "$@" | 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.


_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[email protected]"

Reply via email to