Suppose I have a text file filename.txt
cat filename.txt
abc#123
def#456
Now I want to use IFS in such a way that two arrays are created such as:
source=(abc def)
dest=(123 456)
What would be the logic to create the two separate arrays?
You can re-direct your input file to a while/read loop and set the IFS value to # to split the line contents. Should work on any bash/ksh or zsh shell.
while IFS=# read -r s d; do
source+=( "$s" )
dest+=( "$d" )
done < filename.txt