Bash newbie here. I have a string in the variable IN
and I want to split it into an array when the delimiter ;
is found. Reading different stack exchange answers (this one specifically), I tried this:
#!/bin/bash
IN="12;25;365"
IFS=";" read -r -a ARR <<< "$IN"
echo $ARR
The output is 12
. Interestingly, if I try the following commands in zsh:
IN="12;25;365"
IFS=";" read -r -A ARR <<< "$IN"
echo $ARR
The output will be 12 25 365
.
What am I doing wrong in the bash script? I need that working in bash...