I'm using IFS=', '
to split a string of comma-delimited text into an array. The problem is that occasionally one of the comma-delimited items contains a space following a :
. The resulting array contains that item as two separate array elements. Is it possible to set IFS to only split ', '
and ignore a comma-delimited item that contains ': '
(or any other character for that matter)?
See the comma-delimited string returned from the first command below, note the second item has the :
. See the MarkerNames[1] and MarkerNames[2]
to see the unwanted split in the second command below.
$ exiftool -s3 -TracksMarkersName audioFile.wav
Marker1, Tempo: 120.0, Silence, Marker2, Silence.1, Marker3, Silence.2, Marker4, Silence.3, Marker5
$ IFS=', ' read -r -a MarkerNames <<< $(exiftool -s3 -TracksMarkersName audioFile.wav)
$ declare -p MarkerNames
declare -a MarkerNames='([0]="Marker1" [1]="Tempo:" [2]="120.0" [3]="Silence" [4]="Marker2" [5]="Silence.1" [6]="Marker3" [7]="Silence.2" [8]="Marker4" [9]="Silence.3" [10]="Marker5")'