N
N
NO_GLITCH2015-07-18 03:22:23
bash
NO_GLITCH, 2015-07-18 03:22:23

How to substitute the value of a variable from a file in bash?

I want to automate a small task
Here is a sketch of a bash script, it works "by the piece" - each time I enter the IP

#!/bin/bash
echo "Enter IP"
read ip_addr
echo
echo
echo Посылаем обратный dns-запрос
dns_query_1=$(nslookup $ip_addr  | grep -oP  "name = \K[^ ]+\.*")
dns_query_2=$(echo ${dns_query_1::-1})
echo
echo $dns_query_2
curl --silent http://counter.yadro.ru/values?site=$dns_query_2 | grep 'LI_day_vis'
echo "Ок"

The task is to take a file with a list of IP addresses (written in a column) and pass each address through the script.
Write the results to a file in the format
example0.com - 100500 visits/day
example1.com - 100501 visits/day
example2.com - 100502 visits/day
Faced another curl output problem
curl --silent http://counter.yadro.ru/values?site=habr.ru | grep 'LI_day_vis'
LI_day_vis = 422;

Tell me how to leave only numbers in the output of curl ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2015-07-18
@NO_GLITCH

while read -r host
do
    echo "${host}"
done < /path/to/file

curl --silent http://counter.yadro.ru/values?site=habr.ru | grep 'LI_day_vis' | tr -cd [:digit:]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question