[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Splitting variable into two numbers
From: |
Chris F.A. Johnson |
Subject: |
Re: Splitting variable into two numbers |
Date: |
Tue, 20 Jul 2021 15:37:32 -0400 (EDT) |
User-agent: |
Alpine 2.22 (DEB 394 2020-01-19) |
On Tue, 20 Jul 2021, 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.
Input:
var="{5,8}"
Output:
p=5
q=8
var="{5,8}"
IFS=, read p q <<< "${var//[\{\}]/}"
echo "p=$p"
echo "q=$q"
--
Chris F.A. Johnson <http://cfajohnson.com/>
=========================== Author: ===============================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux shell (2009, Apress)
- Splitting variable into two numbers, lisa-asket, 2021/07/20
- Re: Splitting variable into two numbers, Leonid Isaev (ifax), 2021/07/20
- Re: Splitting variable into two numbers, Greg Wooledge, 2021/07/20
- Splitting variable into two numbers, lisa-asket, 2021/07/20
- Re: Splitting variable into two numbers, Greg Wooledge, 2021/07/20
- Splitting variable into two numbers, lisa-asket, 2021/07/20
- Re: Splitting variable into two numbers, Greg Wooledge, 2021/07/20
- Splitting variable into two numbers, lisa-asket, 2021/07/20
- Re: Splitting variable into two numbers, Greg Wooledge, 2021/07/20
- Re: Splitting variable into two numbers, ikhxcsz7y xmbott, 2021/07/21
Re: Splitting variable into two numbers,
Chris F.A. Johnson <=