Bash IFS not splitting string correctly -
i having trouble getting ifs split string correctly based on colon delimiter. seems -e
inside string being considered option instead of being considered literal string.
#!/bin/bash string_val="-e:sqa" ifs=: read -a items <<< "$string_val" echo "${items[0]}" # prints empty value echo "${items[1]}" # prints sqa
how can fixed?
the string being split correctly; -e
in ${items[0]}
treated option echo
.
$ string_val="-e:sqa" $ ifs=: read -a items <<< "$string_val" $ printf '%s\n' "${items[0]}" -e
Comments
Post a Comment