help-bash
[Top][All Lists]
Advanced

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

Re: Splitting variable into two numbers


From: Greg Wooledge
Subject: Re: Splitting variable into two numbers
Date: Tue, 20 Jul 2021 13:05:01 -0400

On Tue, Jul 20, 2021 at 06:15:32PM +0200, lisa-asket@perso.be wrote:
> I would like to split a variable containing two numbers delimited by a comma 
> 
> and transfer the two numbers into two variables p and q.

p=${input%,*} q=${input#*,}

> Input:
> 
> var="{5,8}"

STOP!

All of a sudden, this is an X-Y problem.  You don't have "two numbers
delimited by a comma".  You have something else entirely.  There are
curly braces now.  I wonder what else is in there.

Is it really JSON?

What's the *actual* goal here?  Where does this input come from, what
does it *really* look like (before any mangling you've already done
on the X-Y path), and what are you trying to do with it?



reply via email to

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