How to use 'readarray' in bash to read lines from a file into a 2D array

后端 未结 6 1760
旧时难觅i
旧时难觅i 2021-02-04 06:35

Let\'s say I have a text file \'demo.txt\' who has a table in it like this:

1 2 3    
4 5 6    
7 8 9    

Now, I want to read each line separat

6条回答
  •  故里飘歌
    2021-02-04 06:51

    To expand on Damien's answer (and because I can't submit comments yet...) you just iterate on read. What I mean is something like the following

    exec 5

    I hope you found a solution already (sorry to bump...). I stumbled upon this page while helping teach a friend and figured others may do the same.

提交回复
热议问题