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

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -