| Deutsch English Français Italiano |
|
<vrsjva$1oouq$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Pancho <Pancho.Jones@protonmail.com>
Newsgroups: comp.os.linux.misc
Subject: Re: Useless Use Of Regexes
Date: Mon, 24 Mar 2025 21:48:26 +0000
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <vrsjva$1oouq$1@dont-email.me>
References: <vrsfkv$1md7d$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 24 Mar 2025 22:48:27 +0100 (CET)
Injection-Info: dont-email.me; posting-host="e10f41d1b85c9164eb4c6ce8451d96e6";
logging-data="1860570"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ySMhMd+jLd2ghdOSZQaDOXDVL/snxE44="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cKWwIYUMLu2Z9uLCJep9cTLIbDk=
Content-Language: en-GB
In-Reply-To: <vrsfkv$1md7d$1@dont-email.me>
On 3/24/25 20:34, Lawrence D'Oliveiro wrote:
> Besides the traditional “Useless Use Of Cat” (UUOC) newbie faux pas,
> we can add “Useless Use Of Regexes”.
>
> These can often be quite subtle. I spotted one obvious instance here
> <https://www.zdnet.com/article/5-ways-i-use-regex-in-linux-and-why-theyre-so-essential/>,
> namely this one:
>
> ip addr | grep -Eo '192\.168\.1\.[0-9]{1,3}'
>
Tut Tut!
$ip addr | grep -E '192\.168\.0\.([0-1]?[0-9]?[0-9]?|2[0-4][0-9]|25[0-5])'
Solve a problem with a RegEx, now you have two problems :-)
> which can be more easily written using features built into iproute2 itself:
>
> ip addr show to 192.168.1.0/24
Seriously, though, it is often easier to filter output from a standard
command with grep, than it is to learn all the command flags.