My file which run loop…
$cat /wdc-cron/countries.csv c-ac,ascension_island c-ad,andorra c-ae,united_arab_emirates
My program file
yesterday=$(date --date "1 days ago" +%F) while IFS= read -r line do dir=$(echo $line | awk -F, '{print $1 }') country=$(echo $line | awk -F, '{print $2 }') cd /$dir.whoisdatacenter.com echo $country >> /wdc-cron/count-$yesterday.txt cat /$dir.whoisdatacenter.com/$yesterday-$country-email.csv | wc -l >> /wdc-cron/count-$yesterday.txt awk '{print $country,",",$dir}' done < "/wdc-cron/countries.csv"
My result is
cat count-2020-01-22.txt ascension_island 0 andorra 0 united_arab_emirates 32
My should I do so result come like
ascension_island, 0 andorra, 0 united_arab_emirates, 32
I will be very glad if someone can help me out,
Advertisement
Answer
A possible solution would be to replace the line:
echo $country >> /wdc-cron/count-$yesterday.txt
with:
printf "$country, " >> /wdc-cron/count-$yesterday.txt