#! /bin/bash
#read line for line
read -p "Enter path to file" file
url=""
while read -r line; do
# reading each line
echo "$line"
url="$url $line"
done < "$file"
#-------------------------------------------------------------------
n=0
m=0
while [ $n -lt 5 ]
do
n=$(( n+1))
m=$(( m+1))
#ping url to usable ip for further use
pingurl=$(echo "${url[@]}"| awk '{print $1+$m}')
pingip=$(ping -c 1 $pingurl | grep 'bytes of data' | awk '{print $3}' | awk -F "(" '{print $2}'| awk -F ")" '{print $1}')
echo "$n"; echo "$pingip"
`
done
this is my bash script to put in a file path (with url). then read it line by line and store it in varible $url after that it defines the var. $pingurl by piping the var.$url with awk to print only one url to process via ping . I would like to add for each loop the awk value by 1 . As you see i aproached this by trying to add the value for each loop with the var. $m but it does not work . i am breaking my mind about it maybe some wise guys are able to help me with this issue .
i tried already to display the url with ${url[(1+$m)]}