i have this basic code that i wrote to read a file and place it's values to an array. the source/input file will have multiple strings on it that is separated by a whitespace.
sample_list.txt file contents:
ACCT1 TABLE1
ACCT2 TABLE2
ACCT3 TABLE3
script file: sample_list.sh
#!/bin/bash
vFileDir="sample_list.txt"
declare -a vLnArray
printf " \n"
#read the content of the file by line
while IFS= read vline
do
vLnArray=("$vline")
vStr1="${vLnArray[0]}"
vStr2="${vLnArray[1]}"
echo "vStr1: $vStr1"
echo "vStr2: $vStr2"
vLnCtr=$((vLnCtr+1))
done < "$vFileDir"
when i run the script it gives me this output:
vStr1: ACCT1 TABLE1
vStr2:
vStr1: ACCT2 TABLE2
vStr2:
vStr1: ACCT3 TABLE3
vStr2:
basically this is the expected output:
vStr1: ACCT1
vStr2: TABLE1
vStr1: ACCT2
vStr2: TABLE2
vStr1: ACCT3
vStr2: TABLE3
please help thank you.