Sujet : Re: Useless Use Of Regexes
De : bencollver (at) *nospam* tilde.pink (Ben Collver)
Groupes : comp.os.linux.miscDate : 25. Mar 2025, 16:29:16
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vrui4b$3ju3k$1@dont-email.me>
References : 1
User-Agent : slrn/1.0.3 (Linux)
On 2025-03-24, Lawrence D'Oliveiro <
ldo@nz.invalid> wrote:
namely this one:
>
ip addr | grep -Eo '192\.168\.1\.[0-9]{1,3}'
>
which can be more easily written using features built into iproute2 itself:
>
ip addr show to 192.168.1.0/24
Even if you were going to use regex for that, since the mask is /24,
why not shorten it?
OLD: ip addr | grep -Eo '192\.168\.1\.[0-9]{1,3}'
NEW: ip addr | grep -Eo '192\.168\.1\.'