Artificial intelligent assistant

List with two values in every List Item I want to store a list with name and email address and use it in the single for loop. And I want to do it in Shell. Knowing that shell list has a white space separator list = "john, john@gmail.com" "doe, doe@outlook.com" "jenny, jenny@another.domain" for i,j in $list; do echo "Dear $i, email text" | mail -s "Hello $i" $j done this should work as echo "Dear john, email text" | mail -s "Hello john" john@gmail.com Also if I want to create this list in a separate csv file, how will I use that? E.g name, email john, john@gmail.com jenny, jenny@another.domain doe, doe@outlook.com

If your shell supports them, you could use an associative array for the first case:


declare -A list=([john]="john@gmail.com" [doe]="doe@outlook.com" [jenny]="jenny@another.domain")

for i in "${!list[@]}"; do
echo "Dear $i, email text" | mail -s "Hello $i" "${list[$i]}"
done


For the second case, a while loop:


while IFS=, read -r i j; do
echo "Dear $i, email text" | mail -s "Hello $i" "$j"
done < file.csv


(this assumes your file is correctly formatted CSV, without a header line).

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy d949d27f2762bb61db9adcfddc51cc5c