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

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -