help-bash
[Top][All Lists]
Advanced

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

Re: tokenize honoring quotes


From: Chet Ramey
Subject: Re: tokenize honoring quotes
Date: Fri, 5 Aug 2022 14:32:38 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 8/5/22 1:43 PM, Robert E. Griffith wrote:
Is there an efficient native bash way to tokenize a string into an array honoring potentially nested double and single quotes?

For example...

    $ str='echo "hello world"'

Some variant of this:

str='echo "hello world"'

declare -a a
eval a=\( "$str" \)

declare -p a


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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