|
From: | Emanuel Berg |
Subject: | Re: [OFF TOPIC] Algorithms (was: Re: Too fine design granularity leads to numerous macro/function/command existed in Emacs.) |
Date: | Fri, 13 Aug 2021 15:07:53 +0200 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
2QdxY4RzWzUUiLuE wrote: >> #! /bin/zsh >> longest-line () { >> local f=$1 >> awk '{ print length($0) " " $0; }' $f | sort -n | tail -1 > > Don't sort unless you have to. > > Don't send all that data through two pipes. > > awk '{if(length($0) > length(x)) {x = $0} END {print x}' > > For small files, you won't notice the difference. For large > files, you will. Definitions of "small" and "large" depend > on a lot of things. *thumbs down* -- underground experts united https://dataswamp.org/~incal
[Prev in Thread] | Current Thread | [Next in Thread] |