I am trying to run such sh script to gather geo information about Ip addresses. inputfile.txt is just a one column file with ip addresses in it.
Here is a sample of my input file:
213.100.122.171
213.100.126.188
213.100.129.186
213.100.18.247
213.100.23.238
213.100.26.151
Here is the code that I am using:
#!/usr/bin/env bash
output=outputfile.csv
for i in $( cat "inputfile.txt");
do echo -e "$i,"$( geoiplookup -f /usr/share/GeoIP/GeoLiteCity.dat $i | cut -d' ' -f6,8-9)"" >> $output;
done
When I run this file, the result is like this
213.100.126.188
,LV, N/A, N/A,
213.100.129.186
,SE, N/A, N/A,
213.100.18.247
,LV, N/A, N/A,
213.100.23.238
,LV, N/A, N/A
I want them to be in each own line, like
213.100.126.188,LV, N/A, N/A,
213.100.129.186,SE, N/A, N/A,
213.100.18.247,LV, N/A, N/A,
213.100.23.238,LV, N/A, N/A,
Where i am wrong with my script?