LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   BASH: loading file to array (https://www.linuxquestions.org/questions/programming-9/bash-loading-file-to-array-505560/)

Roger Krowiak 11-28-2006 08:37 AM

BASH: loading file to array
 
I have a question how to load content of text file into the array, where every member of array will present one line of the file.

First, let have file a.txt with following context:
Code:

this is line1
this is line2

When I did
Code:

my_list=($(<a.txt))
the first array member was 'this' and not 'this is line1' as I intended. So I've used the quotes:
Code:

my_list=("$(<a.txt)")
but the result was the whole file a.txt. So is there any way how to tell bash to delimit the context for array member by new line and not by space/tab?

acid_kewpie 11-28-2006 09:26 AM

heh, just like busses, don't mention $IFS for months, then two come along at once.

http://www.linuxquestions.org/questi...d.php?t=505552

Roger Krowiak 11-28-2006 09:48 AM

Quote:

Originally Posted by acid_kewpie
heh, just like busses, don't mention $IFS for months, then two come along at once.

http://www.linuxquestions.org/questi...d.php?t=505552

eh TY for link, once I've noted I should search for $IFS it was easy, so thank you very much. And your note about busses... thank you once again, for making me laugh :-))


All times are GMT -5. The time now is 09:02 AM.