[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Have Bash to parse multiple space-contained words connected by \, t
From: |
Daniel Mills |
Subject: |
Re: Have Bash to parse multiple space-contained words connected by \, the simplest way |
Date: |
Sun, 22 Nov 2020 17:46:53 -0500 |
Resending because I forgot to include the list.
This is one of the rare use cases for read without -r.
To put it in an array like you want:
read -a parts <<<"$s"
printf '%s\n' "${parts[@]}"
On Sun, Nov 22, 2020 at 9:14 AM Budi <budikusasi@gmail.com> wrote:
> How within a string, can we have Bash to parse multiple
> space-contained words connected by escape char \, by the simplest way
> (only 1-2 commands/lines) ?
>
> s="English phrases must be understood are as\ well, even\ if, as\ such"
> How to achieve kind of in few variables (or enclosed by quote pair
> instead of double quote):
>
> a="English"
> b="phrases"
> c="must"
> d="be"
> e="understood"
> f="are"
> g="as well,"
> h="even if,"
> i="as such"
> or as array of s variable itself, etc
>
>