Reputation: 21174
I've been stuck on this, and can't seem to find any good tips on getting this to work. Okay, so I have this file called "tweets" which has a couple hundred lines. I need to get each line as it's own variable.
Example:
root@host:~$ cat tweets
this is line one
this is line two
this is line three
Alright, so I need each line to be set as a variable. Thanks!
Upvotes: 2
Views: 91
Reputation: 246807
In bash, use mapfile
to read the file into an array:
$ mapfile -t var < tweets
$ echo "${var[0]}"
this is line one
$ echo "${var[2]}"
this is line three
Upvotes: 1