Q:

" echo" in bash script empty file

I have problem with echo command I need export data to csv but its empty file 
#!/bin/bash 
while read domain
do
    ownname= whois $domain | grep -A 1 -i "Administrative Contact:" |cut -d ":" -f 2 | sed 's/ //' | sed -e :a -e '$!N;s/ \n/,/;ta'
    echo -e  "$ownname" >> test.csv 
done < dom.txt

A:

You need to use command substitution to store command's output in a shell variable:
#!/bin/bash 
while read domain; do
    ownname=$(whois $domain | grep -A 1 -i "Administrative Contact:" |cut -d ":" -f 2 | sed 's/ //' | sed -e :a -e '$!N;s/ \n/,/;ta')
    echo -e  "$ownname" >> test.csv
done

PS: I haven't tested all the piped commands.

