Reputation: 8759
I am using this snippet to split string into array
line=FOO=BAR
arr=(${line//=/ })
which can be later used such as (to obtain split values):
varname=${arr[0]}
Works great in zsh environment but, it doesn't work within Alpine Linux /bin/sh
(perhaps, ash
) environment. I am getting:
./env.sh: line 15: syntax error: unexpected "(" (expecting "done")
Is there equivalent string splitting command which works on Alpine Linux?
Upvotes: 0
Views: 784
Reputation: 295687
Using a heredoc:
line=FOO=BAR
IFS='=' read -r var value <<EOF
$line
EOF
Upvotes: 2