Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: autoload variables



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.

		Anthony.





Messages sorted by: Reverse Date, Date, Thread, Author