|
|
|
|
|
by pizza234
1787 days ago
|
|
> The extra overhead and impact on runtime of context switching to load in a new program is non-trivial if you have to loop over it thousands of times The specification is: "speed does not matter". The long answer addresses this solution: $ string="Los Angeles, London, Belfast, New York"
$ IFS="," read -r -a array <<< "${string/, /,}"
$ echo ${array[0]}
Los Angeles
$ echo ${array[1]}
London
as "not very generic" in point #3, which is correct. Bash simply doesn't support generic splitting by itself (things go downhill quickly once, for example, newlines are introduced, and so on), and if precision/flexibility are priority over speed, then it's better to use standard linux tools. |
|