If I have a file example1.txt containing multiple strings
str1
str2
str3
...
I can read them into a bash array by using
mapfile -t mystrings < example1.txt.
Now say my file example2.txt is formatted as a table
str11 str12 str13
str21 str22 str23
str31 str32 str33
... ... ...
and I want to read each column into a different array. I know I can use other tools such as awk to separate each line into fields. Is there some way to combine this functionality with mapfile? I'm looking for something like
mapfile -t firstcol < $(cat example2.txt | awk '//{printf $1"\n"}')
mapfile -t secondcol < $(cat example2.txt | awk '//{printf $2"\n"}')
(which doesn't work).
Any other suggestion on how to handle a table in bash is also welcome.