help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find the longest word in the word list file.


From: Emanuel Berg
Subject: Re: Find the longest word in the word list file.
Date: Wed, 11 Aug 2021 18:09:29 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hongyi Zhao wrote:

> I have an English word list file that stores words in
> a one-word-per-line format. Now I want to find the longest
> word in the word list file. For example, I can use standard
> UNIX tools to accomplish this with the following simple
> commands:
>
> $ awk '$0 ~ /^[[:alpha:]]+$/ { print $0, length($0) }'
> american-english-exhaustive | \
> sort -k2n | tail -1
> Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch 58

#! /bin/zsh
longest-line () {
    local f=$1
    awk '{ print length($0) " " $0; }' $f | sort -n | tail -1
}

$ longest-line american-english-insane 
60 Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch's

> But in Emacs, what is the elisp implementation for the
> above task?

This is one better suited for the shell IMO.

Hm... is that really a word?

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]