I'm trying to split a line with multiple ' in it, but the result are numbers, not strings, trying to get the 1st occurrence of ', I mean the string YouTube down there:
line="application: label='YouTube' icon='res/uFR.xml'"
echo $line
IFS="'"
read -a stringArray <<< "$line"
echo "${stringArray[1]}"
Current Output:
112
Expected Output:
YouTube
IFSglobally like this can cause all sorts of weird problems, especially when you're also using word splitting (which depends onIFS) to get the items theforloop iterates over (which also isn't very safe on its own, either). It's better to make it a prefix of thereadcommand (IFS=\' read -a ...) so that it only applies to that one command.line=.. / echo $line / IFS=... / read -a ... / echo ...) works for me and generates as output the stringYouTube; and the array contents look correct:typeset -p stringArray=>declare -a stringArray=([0]="application: label=" [1]="YouTube" [2]=" icon=" [3]="res/uFR.xml")adb