To read a file line by line from BASH you can use one of the following options:
For example, if we have the following file (emails.txt):
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
$ while read line; do echo "Sending email to $line"; done < emails.txt
$ cat emails.txt |while read line; do echo "Sending email to $line"; done
I suggest AWK if the file has more than one column since AWK allows to specify columns separator, if we have the following file:
Sybil|[email protected]
Neville|[email protected]
Sean|[email protected]
then we can type:
awk -F'|' '{email=$1" <"$2">"} {print "Sending email to "email;}' emails.txt