|
From: | 2QdxY4RzWzUUiLuE |
Subject: | [OFF TOPIC] Algorithms (was: Re: Too fine design granularity leads to numerous macro/function/command existed in Emacs.) |
Date: | Fri, 13 Aug 2021 06:00:22 -0700 |
On 2021-08-13 at 12:11:29 +0200, Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> 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. > }
[Prev in Thread] | Current Thread | [Next in Thread] |