bash - How can I increment one line at a time from a text file and sed the output to another file? -
i have text file containing, e.g.:
user0@domain.com user1@domain.com user2@domain.com user3@domain.com
and ssmtp.conf containing:
authuser=user0@domain.com
how can take first line , sed
ssmtp.conf end this:
authuser=user1@domain.com
i need sleep few seconds , change
authuser=user2@domain.com
and forth. currently, of couple users here have:
#!/bin/bash y=4 (( x=1; x<=y; x++ )); emails=`echo $( cat /home/apx/desktop/emailaddresses.txt | sed -n ''$x''p )` sed -i "/authuser/s/= .*/= $emails/" /etc/ssmtp/ssmtp.conf ssmtp blahh@blahh.com -v < /home/apx/desktop/message.txt sleep 1 done
when run this, cycles through 4 times. each time sends email, sends 4 user0@domain.com rather user0, user1, user2, , user3, i've been struggling achieve. realized not changing @ all. stays way left last. appreciate if me understand i'm doing wrong.
try this:
#! /bin/bash while read -r addr; sudo m4 -daddr="$addr" >/etc/ssmtp/ssmtp.conf <<<'authuser=addr' sudo ssmtp blahh@blahh.com -v </home/apx/desktop/message.txt sleep 1 done </home/apx/desktop/emailaddresses.txt
Comments
Post a Comment