I am using a command in my shell script that returns multiple strings, each enclosed inside "". Since I need each of these strings as separate elements of an array, I am splitting this collection of strings by using " as the delimiter, like this:
IFS='"'
arr=($(command that returns multiple strings enclosed in ""))
Now, since there is a " character at the beginning of each string, my script splits each string into a blank string and the string itself. For example, the strings "foo" "bar" will be split into  (empty string), foo,  (empty string again), and bar. So my array ends up having 4 elements, instead of 2.
There can be two approaches to overcome this, and any help in implementing either would be helpful:
- Somehow getting rid of the whitespace while splitting.
- Creating the array with the whitespaces, and then creating another array, and only inserting those elements from the first into the second array which are not whitespaces.
I am tagging the answer as both bash and ksh as a solution is bash would be acceptable too. Thanks!
 
     
    