I'm trying to grep from file with similar text:
1.1.1.1-Text1
2.2.2.2-Text2
3.3.3.3-Text3
and put each grep result as different variable to get this:
ip=$(cat nodes.txt | grep -o '^[^-]*')
curl -k -sL -w 'Response Code: %{http_code} Time: %{time_total}' $ip -o /dev/null # variable IP with value of 1.1.1.1
curl -k -sL -w 'Response Code: %{http_code} Time: %{time_total}' $ip -o /dev/null # variable IP with value of 2.2.2.2
curl -k -sL -w 'Response Code: %{http_code} Time: %{time_total}' $ip -o /dev/null # variable IP with value of 3.3.3.3
so my test results would look like this:
Test from 1.1.1.1-Text1 Response Code: 200 Time: 0.000
Test from 2.2.2.2-Text2 Response Code: 200 Time: 0.000
Test from 3.3.3.3-Text3 Response Code: 200 Time: 0.000