All you have to do is:
readarray myData < sqlfile
This will put the lines of the file into an array called myData
Now you can access any of the following lines:
printf "%s\n" "${myData[0]}" #outputs first line printf "%s\n" "${myData[2]}" #outputs third line
And you can iterate over it:
for curLine in "${myData[@]}"; do echo "$curLine" done
Note that these lines will contain the \n character. To remove trailing newlines, you can use the -t flag as follows:
readarray -t myData < sqlfile
readarray is synonymous with mapfile . You can read about it in man bash
source share