Zsh Mailing List Archive
Messages sorted by:
Re: autoload variables
- X-seq: zsh-users 27075
- From: Anthony Fletcher <anthony@xxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: Marc Chantreux <eiro@xxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: autoload variables
- Date: Thu, 2 Sep 2021 19:09:50 -0400
- Archived-at: <https://zsh.org/users/27075>
- In-reply-to: <CAN=4vMpQRnfTcRZHcz1+=PQ8VMOfTBvoKPSNC8-9cRwqDeYM6Q@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- Mail-followup-to: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>, Marc Chantreux <eiro@xxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- References: <CAPT4cGdBZQDQv8ozkpgYwzm60yqmpJwCKCSPUnLaAj-Rp+F6kg@mail.gmail.com> <YS6TI9eVkktkyvfJ@prometheus.u-strasbg.fr> <CAN=4vMr9DiCejUiWeLfB6M29Jj4qb+kuKAuYR-n-X-riMqAVcQ@mail.gmail.com> <YS85/tOk0c9niPe4@prometheus.u-strasbg.fr> <CAN=4vMpQRnfTcRZHcz1+=PQ8VMOfTBvoKPSNC8-9cRwqDeYM6Q@mail.gmail.com>
On 01 Sep 2021 at 11:51:30, Roman Perepelitsa wrote:
> On Wed, Sep 1, 2021 at 10:30 AM Marc Chantreux <eiro@xxxxxxxxx> wrote:
> > Hi Roman,
> > Le Tue, Aug 31, 2021 at 11:03:39PM +0200, Roman Perepelitsa a écrit :
> > > sed -n -e '/^default/ s/^default.*dev //; s/ .*// p;q'
> > > In plain English:
> > english is fine. can you confirm that '/^default/ s/^default.*dev //'
> > is a suttered way to say 's/^default.*dev //' ?
> Yes, these are equivalent. Anything that matches '^default.*dev '
> matches '^default'.
Yes but the point is I am only interested in lines that start with
'default via'. I am ignoring all the other lines. Without the initial
match /^default/ all the other lines are processed by the
substitutions and I get the wrong interface.
> > that's what i was afraid about. does ip r garanty that?
> I don't know. FWIW, I'd do it like this:
> ip -j -4 r | jq -r '. | select(.dst == "default") | .dev'
> This requires a new-enough version of ip to support json output.
Cool - I didn't know JSON output was an option. Not that jq is much less
baroque than sed. I think this is better than my sed script.
One point in favour of sed - it's then on all systems, jq isn't.
Sorry for the off-topic discussion.
Messages sorted by: